diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index e89a8ee4..e51ae6b3 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -104,7 +104,7 @@ sodium_bin2hex(char * const hex, const size_t hex_maxlen, size_t j = (size_t) 0U; if (bin_len >= SIZE_MAX / 2 || hex_maxlen < bin_len * 2U) { - abort(); + abort(); /* LCOV_EXCL_LINE */ } while (i < bin_len) { hex[j++] = hexdigits[bin[i] >> 4]; @@ -298,11 +298,11 @@ _alloc_aligned(const size_t size) if ((ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_NOCORE, -1, 0)) == MAP_FAILED) { ptr = NULL; /* LCOV_EXCL_LINE */ - } + } /* LCOV_EXCL_LINE */ #elif defined(HAVE_POSIX_MEMALIGN) if (posix_memalign(&ptr, page_size, size) != 0) { ptr = NULL; /* LCOV_EXCL_LINE */ - } + } /* LCOV_EXCL_LINE */ #elif defined(_WIN32) ptr = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #elif !defined(HAVE_ALIGNED_MALLOC) diff --git a/test/default/sodium_utils2.c b/test/default/sodium_utils2.c index 312cfca0..11f1df68 100644 --- a/test/default/sodium_utils2.c +++ b/test/default/sodium_utils2.c @@ -29,9 +29,16 @@ int main(void) size_t size; unsigned int i; + if (sodium_malloc(SIZE_MAX - 1U) != NULL) { + return 1; + } if (sodium_allocarray(SIZE_MAX / 2U + 1U, SIZE_MAX / 2U) != NULL) { return 1; } + buf = sodium_allocarray(1000U, 50U); + memset(buf, 0, 50000U); + sodium_free(buf); + sodium_free(sodium_malloc(0U)); sodium_free(NULL); for (i = 0U; i < 10000U; i++) {