Skip to content

Commit

Permalink
sudo_mmap_strdup_v1: Fix potential NULL pointer deref
Browse files Browse the repository at this point in the history
  • Loading branch information
BornThisWay committed Nov 20, 2022
1 parent 9c694e9 commit 1eabf13
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/util/mmap_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ sudo_mmap_strdup_v1(const char *str)
return NULL;
}
newstr = sudo_mmap_alloc_v1(len + 1);
memcpy(newstr, str, len);
newstr[len] = '\0';
if (newstr != NULL) {
memcpy(newstr, str, len);
newstr[len] = '\0';
}

return newstr;
}
Expand Down

0 comments on commit 1eabf13

Please # to comment.