mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
unzip: Fix segmentation fault if a zip file contains buggy filename.
PR: 259011 Reported by: Robert Morris Submitted by: ak MFC after:: 1 week
This commit is contained in:
parent
b158d4d7a1
commit
2c614481fd
|
@ -211,6 +211,9 @@ pathdup(const char *path)
|
||||||
char *str;
|
char *str;
|
||||||
size_t i, len;
|
size_t i, len;
|
||||||
|
|
||||||
|
if (path == NULL || path[0] == '\0')
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
len = strlen(path);
|
len = strlen(path);
|
||||||
while (len && path[len - 1] == '/')
|
while (len && path[len - 1] == '/')
|
||||||
len--;
|
len--;
|
||||||
|
@ -697,7 +700,11 @@ extract(struct archive *a, struct archive_entry *e)
|
||||||
mode_t filetype;
|
mode_t filetype;
|
||||||
char *p, *q;
|
char *p, *q;
|
||||||
|
|
||||||
pathname = pathdup(archive_entry_pathname(e));
|
if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) {
|
||||||
|
warningx("skipping empty or unreadable filename entry");
|
||||||
|
ac(archive_read_data_skip(a));
|
||||||
|
return;
|
||||||
|
}
|
||||||
filetype = archive_entry_filetype(e);
|
filetype = archive_entry_filetype(e);
|
||||||
|
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
|
@ -760,7 +767,11 @@ extract_stdout(struct archive *a, struct archive_entry *e)
|
||||||
char *pathname;
|
char *pathname;
|
||||||
mode_t filetype;
|
mode_t filetype;
|
||||||
|
|
||||||
pathname = pathdup(archive_entry_pathname(e));
|
if ((pathname = pathdup(archive_entry_pathname(e))) == NULL) {
|
||||||
|
warningx("skipping empty or unreadable filename entry");
|
||||||
|
ac(archive_read_data_skip(a));
|
||||||
|
return;
|
||||||
|
}
|
||||||
filetype = archive_entry_filetype(e);
|
filetype = archive_entry_filetype(e);
|
||||||
|
|
||||||
/* I don't think this can happen in a zipfile.. */
|
/* I don't think this can happen in a zipfile.. */
|
||||||
|
|
Loading…
Reference in a new issue