Skip to content

Commit

Permalink
Fix zpool_history_unpack unconditionally returning ENOMEM on nvlist_u…
Browse files Browse the repository at this point in the history
…npack failure

Signed-off-by: WHR <[email protected]>
  • Loading branch information
Low-power committed Apr 12, 2022
1 parent 35d81a7 commit edd685a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/libzutil/zutil_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ zpool_history_unpack(char *buf, uint64_t bytes_read, uint64_t *leftover,
nvlist_t *nv;
int i;
void *tmp;
int err;

while (bytes_read > sizeof (reclen)) {

Expand All @@ -120,8 +121,9 @@ zpool_history_unpack(char *buf, uint64_t bytes_read, uint64_t *leftover,
break;

/* unpack record */
if (nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0) != 0)
return (ENOMEM);
err = nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0);
if (err != 0)
return (err);
bytes_read -= sizeof (reclen) + reclen;
buf += sizeof (reclen) + reclen;

Expand Down

0 comments on commit edd685a

Please sign in to comment.