Skip to content

Commit 77755b6

Browse files
committed
Backport CVE patches.
CVE-2011-0421 (nih-at/libzip@88efa42) CVE-2015-2331 (php/php-src@ef8fc4b) Fix MSVC build strcasecmp has a Watcom-native implementation and is portable sans Windows. This replaces a prior stricmp call, which is deprecated in the Watcom C library.
1 parent 6280052 commit 77755b6

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

contrib/libzip/lib/zdirent.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ _zip_cdir_new(int nentry, struct zip_error *error)
8181
_zip_error_set(error, ZIP_ER_MEMORY, 0);
8282
return NULL;
8383
}
84-
85-
if ((cd->entry=malloc(sizeof(*(cd->entry))*nentry)) == NULL) {
84+
85+
if ( nentry > ((size_t)-1)/sizeof(*(cd->entry)) || (cd->entry=(struct zip_dirent *)malloc(sizeof(*(cd->entry))*(size_t)nentry))
86+
== NULL) {
8687
_zip_error_set(error, ZIP_ER_MEMORY, 0);
8788
free(cd);
8889
return NULL;

contrib/libzip/lib/znameloc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636

3737

3838
#include <string.h>
39+
#ifdef _MSC_VER
40+
#define strcasecmp _stricmp
41+
#else
42+
#include <strings.h>
43+
#endif
3944

4045
#include "wio.h"
4146

@@ -64,8 +69,13 @@ _zip_name_locate(struct zip *za, const char *fname, int flags,
6469
_zip_error_set(error, ZIP_ER_INVAL, 0);
6570
return -1;
6671
}
72+
73+
if ((flags & ZIP_FL_UNCHANGED) && za->cdir == NULL) {
74+
_zip_error_set(error, ZIP_ER_NOENT, 0);
75+
return -1;
76+
}
6777

68-
cmp = (flags & ZIP_FL_NOCASE) ? stricmp : strcmp;
78+
cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp;
6979

7080
n = (flags & ZIP_FL_UNCHANGED) ? za->cdir->nentry : za->nentry;
7181
for (i=0; i<n; i++) {

0 commit comments

Comments
 (0)