diff options
Diffstat (limited to 'src/Common/libzip/zip_name_locate.c')
-rw-r--r-- | src/Common/libzip/zip_name_locate.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Common/libzip/zip_name_locate.c b/src/Common/libzip/zip_name_locate.c index 806053cc..4248dc2d 100644 --- a/src/Common/libzip/zip_name_locate.c +++ b/src/Common/libzip/zip_name_locate.c @@ -49,20 +49,29 @@ zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags) { zip_int64_t _zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags, zip_error_t *error) { int (*cmp)(const char *, const char *); + size_t fname_length; zip_string_t *str = NULL; const char *fn, *p; zip_uint64_t i; - if (za == NULL) + if (za == NULL) { return -1; + } if (fname == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); return -1; } + fname_length = strlen(fname); + + if (fname_length > ZIP_UINT16_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + if ((flags & (ZIP_FL_ENC_UTF_8 | ZIP_FL_ENC_RAW)) == 0 && fname[0] != '\0') { - if ((str = _zip_string_new((const zip_uint8_t *)fname, strlen(fname), flags, error)) == NULL) { + if ((str = _zip_string_new((const zip_uint8_t *)fname, (zip_uint16_t)strlen(fname), flags, error)) == NULL) { return -1; } if ((fname = (const char *)_zip_string_get(str, NULL, 0, error)) == NULL) { |