mirror of
https://github.com/AuxXxilium/kmod.git
synced 2025-02-10 19:05:58 +07:00
libkmod-file: gracefully handle errors from zlib
zlib won't necessarily set the system errno, and this is particularly evident on corrupted data (which results in a double free). Use zlib's gzerror to detect the failure, returning a generic EINVAL when zlib doesn't provide us with an errno.
This commit is contained in:
parent
4321590770
commit
c7d5a60d3d
@ -199,7 +199,13 @@ static int load_zlib(struct kmod_file *file)
|
||||
if (r == 0)
|
||||
break;
|
||||
else if (r < 0) {
|
||||
err = -errno;
|
||||
int gzerr;
|
||||
const char *gz_errmsg = gzerror(file->gzf, &gzerr);
|
||||
|
||||
ERR(file->ctx, "gzip: %s\n", gz_errmsg);
|
||||
|
||||
/* gzip might not set errno here */
|
||||
err = gzerr == Z_ERRNO ? -errno : -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
did += r;
|
||||
|
Loading…
Reference in New Issue
Block a user