Mention that mlock() failing is not a hard error for sodium_malloc()

This commit is contained in:
Frank Denis 2022-12-19 12:12:05 +01:00
parent 374a58c1e1
commit 4acf8befe0

View File

@ -616,7 +616,7 @@ _sodium_malloc(const size_t size)
memcpy(unprotected_ptr + unprotected_size, canary, sizeof canary); memcpy(unprotected_ptr + unprotected_size, canary, sizeof canary);
# endif # endif
_mprotect_noaccess(unprotected_ptr + unprotected_size, page_size); _mprotect_noaccess(unprotected_ptr + unprotected_size, page_size);
sodium_mlock(unprotected_ptr, unprotected_size); (void) sodium_mlock(unprotected_ptr, unprotected_size); /* not a hard error in the context of sodium_malloc() */
canary_ptr = canary_ptr =
unprotected_ptr + _page_round(size_with_canary) - size_with_canary; unprotected_ptr + _page_round(size_with_canary) - size_with_canary;
user_ptr = canary_ptr + sizeof canary; user_ptr = canary_ptr + sizeof canary;
@ -686,7 +686,7 @@ sodium_free(void *ptr)
_out_of_bounds(); _out_of_bounds();
} }
# endif # endif
sodium_munlock(unprotected_ptr, unprotected_size); (void) sodium_munlock(unprotected_ptr, unprotected_size);
_free_aligned(base_ptr, total_size); _free_aligned(base_ptr, total_size);
} }
#endif /* HAVE_ALIGNED_MALLOC */ #endif /* HAVE_ALIGNED_MALLOC */