]> err.no Git - dpkg/commitdiff
Apply patch from Fumitoshi UKAI <ukai@debian.or.jp>, that escapes invalid
authorAdam Heath <doogie@debian.org>
Thu, 19 Apr 2001 05:06:56 +0000 (05:06 +0000)
committerAdam Heath <doogie@debian.org>
Thu, 19 Apr 2001 05:06:56 +0000 (05:06 +0000)
characters in filenames(intl).

ChangeLog
debian/changelog
main/archives.c

index 5318c16412b2aba6536b3578e0f5a28fd78e9b04..0dc83498825b9df89fc420fe2347b88114833494 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Apr 19 00:03:16 CDT 2001 Adam Heath <doogie@debian.org>
+
+  * main/archives.c:  Apply patch from Fumitoshi UKAI <ukai@debian.or.jp>,
+    that escapes invalid characters in filenames(intl).
+
 Wed Apr 18 23:53:40 CDT 2001 Adam Heath <doogie@debian.org>
 
   * lib/database.c: In blankpackage, intialize ->installed and ->available.
index 948fd82bdf2190b77fb5e2404add63a2667e8b51..7f3be937a72ece046347f58b91de248977fcae55 100644 (file)
@@ -58,6 +58,8 @@ dpkg (1.9.0) unstable; urgency=low
   * Handle window resize in dselect main menu. Closes: Bug#93559
   * Initialize all parts of the package record.  This should fix several
     segfaults people have been seeing in dpkg.  Closes: #90328.
+  * Apply patch from bug#86847, that escapes intl chars in filenames.
+    Closes(rc): #83752, #85040, #86847, #89000.
 
  -- Wichert Akkerman <wakkerma@debian.org>  UNRELEASED
 
index fa7de121b4276e68928d01928fadea2461e7594e..0b601c273e653430e8196069b77e1e8629e7d19a 100644 (file)
 struct pkginfo *conflictor[20];
 int cflict_index = 0;
 
+/* snprintf(3) doesn't work if format contains %.<nnn>s and an argument has
+ * invalid char for locale, then it returns -1.
+ * ohshite() is ok, but fd_fd_copy(), which is used in tarobject() in this
+ * file, is not ok, because
+ * - fd_fd_copy() == buffer_copy_setup() [include/dpkg.h]
+ * - buffer_copy_setup() uses varbufvprintf(&v, desc, al); [lib/mlib.c]
+ * - varbufvpprintf() fails and memory exausted, because it call
+ *    fmt = "backend dpkg-deb during `%.255s'
+ *    arg may contain some invalid char, for example,
+ *    /usr/share/doc/console-tools/examples/unicode/\342\231\252\342\231\254
+ *   in console-tools.
+ *   In this case, if user uses some locale which doesn't support \342\231...,
+ *   vsnprintf() always return -1 and varbufextend() again and again
+ *   and memory exausted and die.
+ *
+ * So, we need to escape invalid char, probably as in
+ * tar-1.13.19/lib/quotearg.c: quotearg_buffer_restyled()
+ * but here I escape all 8bit chars, in order to be simple.
+ * - ukai@debian.or.jp
+ */
+static char *
+quote_filename(char *buf, int size, char *s)
+{
+       char *r = buf;
+       while (size > 0) {
+               switch (*s) {
+               case '\0':
+                       *buf = '\0';
+                       return r;
+               case '\\':
+                       *buf++ = '\\';
+                       *buf++ = '\\';
+                       size -= 2;
+                       break;
+               default:
+                       if (((*s)&0x80) == 0) {
+                               *buf++ = *s++;
+                               --size;
+                       } else {
+                               if (size > 4) {
+                                       sprintf(buf, "\\%03o",
+                                               *(unsigned char *)s);
+                                       size -= 4;
+                                       buf += 4;
+                                       s++;
+                               } else {
+                                       /* buffer full */
+                                       *buf = '\0'; /* XXX */
+                                       return s;
+                               }
+                       }
+               }
+       }
+       *buf = '\0'; /* XXX */
+       return r;
+
+}
+
 int filesavespackage(struct fileinlist *file, struct pkginfo *pkgtobesaved,
                      struct pkginfo *pkgbeinginstalled) {
   struct pkginfo *divpkg, *thirdpkg;
@@ -406,7 +464,9 @@ int tarobject(struct TarInfo *ti) {
     push_cleanup(cu_closefd,ehflag_bombout, 0,0, 1,(void*)fd);
     debug(dbg_eachfiledetail,"tarobject NormalFile[01] open size=%lu",
           (unsigned long)ti->Size);
-    fd_fd_copy(tc->backendpipe, fd, ti->Size, _("backend dpkg-deb during `%.255s'"),ti->Name);
+    { char fnamebuf[256];
+    fd_fd_copy(tc->backendpipe, fd, ti->Size, _("backend dpkg-deb during `%.255s'"),quote_filename(fnamebuf,256,ti->Name));
+    }
     r= ti->Size % TARBLKSZ;
     if (r > 0) r= read(tc->backendpipe,databuf,TARBLKSZ - r);
     if (nifd->namenode->statoverride)