On Tue, Feb 10, 2004 at 04:12:50PM +0100, Ingo Saitz wrote:
> I have a not so clean patch for this problem attached, which workes for
> me but creates memory leaks but is able to unpack those debs correctly.

And now the patch, aargh...


    Ingo
-- 
mail: .signature: No such file or directory
diff -Ndurp dpkg-1.10.18/lib/tarfn.c dpkg-1.10.18.0/lib/tarfn.c
--- dpkg-1.10.18/lib/tarfn.c    2002-08-29 21:58:11.000000000 +0200
+++ dpkg-1.10.18.0/lib/tarfn.c  2004-02-06 04:49:38.000000000 +0100
@@ -86,7 +86,26 @@ DecodeTarHeader(char * block, TarInfo * 
        if ( group )
                d->GroupID = group->gr_gid;
 
-       
+       /* fix for non null terminated Name field */
+       if (strlen (h->Name) > 100) {
+               /* FIXME: memory leak */
+               char *p = calloc (1, 101);
+               if (p) {
+                       memcpy (p, h->Name, 100);
+                       d->Name = p;
+               }
+       }
+
+       /* fix for non null terminated LinkName field */
+       if (strlen (h->LinkName) > 100) {
+               /* FIXME: memory leak */
+               char *p = calloc (1, 101);
+               if (p) {
+                       memcpy (p, h->LinkName, 100);
+                       d->LinkName = p;
+               }
+       }
+
        sum = ' ' * sizeof(h->Checksum);/* Treat checksum field as all blank */
        for ( i = TarChecksumOffset; i > 0; i-- )
                sum += *s++;

Reply via email to