Skip to content

Commit

Permalink
Correctly check for mmap failure
Browse files Browse the repository at this point in the history
POSIX `mmap` returns MAP_FAILED on error, not NULL. This commit
modifies the `mmap` failure check appropriately.

Noticed the potential issue while reading this:
https://opensslrampage.org/post/98734688405/
  • Loading branch information
codylico committed May 19, 2020
1 parent 1e31173 commit 689e578
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mmaptwo.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ struct mmaptwo_page_i* mmaptwo_mmt_acquire
}
ptr = mmap(NULL, fullsize, mmaptwo_mode_prot_cvt(mu->mt.mode),
mmaptwo_mode_flag_cvt(mu->mt.privy), mu->fd, fulloff);
if (ptr == NULL) {
if (ptr == MAP_FAILED) {
free(out);
return NULL;
}
Expand Down

0 comments on commit 689e578

Please sign in to comment.