Microsoft's static analysis tool found some vulnerabilities from
unguarded null references that I changed in
[microsoft/cmake](https://github.com/microsoft/cmake). Pushing these
changes upstream so they can be added to
[kitware/cmake](https://github.com/Kitware/CMake).
ssize_t bytes_avail = 0;
const uint8_t* data = __archive_read_ahead(a,
(size_t)zip->ppstream.stream_in+1, &bytes_avail);
- if(bytes_avail < zip->ppstream.stream_in+1) {
+ if(data == NULL || bytes_avail < zip->ppstream.stream_in+1) {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated 7z file data");
struct archive_entry *trailer;
trailer = archive_entry_new2(NULL);
+ if (trailer == NULL) {
+ return ARCHIVE_FATAL;
+ }
/* nlink = 1 here for GNU cpio compat. */
archive_entry_set_nlink(trailer, 1);
archive_entry_set_size(trailer, 0);
struct archive_entry *trailer;
trailer = archive_entry_new2(NULL);
+ if (trailer == NULL) {
+ return ARCHIVE_FATAL;
+ }
/* nlink = 1 here for GNU cpio compat. */
archive_entry_set_nlink(trailer, 1);
archive_entry_set_size(trailer, 0);