]> granicus.if.org Git - php/commitdiff
fix potentially serious security issue: buffer overrun if the tar filename > 101...
authorGreg Beaver <cellog@php.net>
Fri, 25 Apr 2008 04:35:10 +0000 (04:35 +0000)
committerGreg Beaver <cellog@php.net>
Fri, 25 Apr 2008 04:35:10 +0000 (04:35 +0000)
ext/phar/tar.c

index 7c804d5d627d81123707e69d3b782421d54cad70..fccc33c5a780a0671b8a00ab3e806f1ffb2b201f 100644 (file)
@@ -208,7 +208,12 @@ int phar_open_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, i
                        char name[256];
 
                        strcpy(name, hdr->prefix);
-                       strcat(name, hdr->name);
+                       /* remove potential buffer overflow */
+                       if (hdr->name[99]) {
+                               strncat(name, hdr->name, 100);
+                       } else {
+                               strcat(name, hdr->name);
+                       }
                        entry.filename_len = strlen(hdr->prefix) + 100;
                        if (name[entry.filename_len - 1] == '/') {
                                /* some tar programs store directories with trailing slash */