Bugzilla – Attachment 680967 Details for
Bug 984945
zip doesn't check readdir return value
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Forgot Password
[patch]
Check readdir for errors
zip-readdir.diff (text/plain), 1.77 KB, created by
Forgotten User zVnB049thN
on 2016-06-15 22:54:52 UTC
(
hide
)
Description:
Check readdir for errors
Filename:
MIME Type:
Creator:
Forgotten User zVnB049thN
Created:
2016-06-15 22:54:52 UTC
Size:
1.77 KB
patch
obsolete
>diff -ur zip30.orig/unix/unix.c zip30-pjb/unix/unix.c >--- zip30.orig/unix/unix.c 2016-06-15 23:49:02.357451760 +0100 >+++ zip30-pjb/unix/unix.c 2016-06-15 23:47:25.453143250 +0100 >@@ -13,6 +13,7 @@ > #ifndef UTIL /* the companion #endif is a bit of ways down ... */ > > #include <time.h> >+#include <errno.h> > > #if defined(MINIX) || defined(__mpexl) > # ifdef S_IWRITE >@@ -176,29 +177,36 @@ > } > } > /* recurse into directory */ >- if (recurse && (d = opendir(n)) != NULL) >+ if (recurse) > { >- while ((e = readd(d)) != NULL) { >- if (strcmp(e, ".") && strcmp(e, "..")) >- { >- if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL) >- { >- closedir(d); >- free((zvoid *)p); >- return ZE_MEM; >- } >- strcat(strcpy(a, p), e); >- if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */ >- { >- if (m == ZE_MISS) >- zipwarn("name not matched: ", a); >- else >- ziperr(m, a); >- } >- free((zvoid *)a); >- } >+ if ((d = opendir(n)) != NULL) { >+ while (errno=0, (e = readd(d)) != NULL) { >+ if (strcmp(e, ".") && strcmp(e, "..")) >+ { >+ if ((a = malloc(strlen(p) + strlen(e) + 1)) == NULL) >+ { >+ closedir(d); >+ free((zvoid *)p); >+ return ZE_MEM; >+ } >+ strcat(strcpy(a, p), e); >+ if ((m = procname(a, caseflag)) != ZE_OK) /* recurse on name */ >+ { >+ if (m == ZE_MISS) >+ zipwarn("name not matched: ", a); >+ else >+ ziperr(m, a); >+ } >+ free((zvoid *)a); >+ } >+ } >+ if (errno) { >+ ziperr(ZE_READ, n); >+ } >+ closedir(d); >+ } else { >+ ziperr(ZE_READ, n); > } >- closedir(d); > } > free((zvoid *)p); > } /* (s.st_mode & S_IFDIR) */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 984945
: 680967