vendor/libsodium/src/libsodium/sodium/utils.c in rbnacl-libsodium-0.7.0 vs vendor/libsodium/src/libsodium/sodium/utils.c in rbnacl-libsodium-1.0.0
- old
+ new
@@ -59,11 +59,11 @@
{
#ifdef _WIN32
SecureZeroMemory(pnt, len);
#elif defined(HAVE_MEMSET_S)
if (memset_s(pnt, (rsize_t) len, 0, (rsize_t) len) != 0) {
- abort();
+ abort(); /* LCOV_EXCL_LINE */
}
#elif defined(HAVE_EXPLICIT_BZERO)
explicit_bzero(pnt, len);
#elif HAVE_WEAK_SYMBOLS
memset(pnt, 0, len);
@@ -102,11 +102,11 @@
};
size_t i = (size_t) 0U;
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];
hex[j++] = hexdigits[bin[i] & 0xf];
i++;
@@ -213,11 +213,11 @@
SYSTEM_INFO si;
GetSystemInfo(&si);
page_size = (size_t) si.dwPageSize;
#endif
if (page_size < CANARY_SIZE) {
- abort();
+ abort(); /* LCOV_EXCL_LINE */
}
randombytes_buf(canary, sizeof canary);
return 0;
}
@@ -285,26 +285,26 @@
raise(SIGSEGV);
#elif defined(SIGKILL)
raise(SIGKILL);
#endif
abort();
-}
+} /* LCOV_EXCL_LINE */
static __attribute__((malloc)) unsigned char *
_alloc_aligned(const size_t size)
{
void *ptr;
#ifdef MAP_ANON
if ((ptr = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE | MAP_NOCORE, -1, 0)) == MAP_FAILED) {
- ptr = NULL;
- }
+ ptr = NULL; /* LCOV_EXCL_LINE */
+ } /* LCOV_EXCL_LINE */
#elif defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&ptr, page_size, size) != 0) {
- ptr = NULL;
- }
+ 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)
ptr = malloc(size);
#else
@@ -336,11 +336,11 @@
canary_ptr = ((unsigned char *) ptr) - sizeof canary;
page_mask = page_size - 1U;
unprotected_ptr_u = ((uintptr_t) canary_ptr & (uintptr_t) ~page_mask);
if (unprotected_ptr_u <= page_size * 2U) {
- abort();
+ abort(); /* LCOV_EXCL_LINE */
}
return (unsigned char *) unprotected_ptr_u;
}
static __attribute__((malloc)) void *
@@ -358,17 +358,17 @@
if (size >= SIZE_MAX - page_size * 4U) {
errno = ENOMEM;
return NULL;
}
if (page_size <= sizeof canary || page_size < sizeof unprotected_size) {
- abort();
+ abort(); /* LCOV_EXCL_LINE */
}
size_with_canary = (sizeof canary) + size;
unprotected_size = _page_round(size_with_canary);
total_size = page_size + page_size + unprotected_size + page_size;
if ((base_ptr = _alloc_aligned(total_size)) == NULL) {
- return NULL;
+ return NULL; /* LCOV_EXCL_LINE */
}
unprotected_ptr = base_ptr + page_size * 2U;
_mprotect_noaccess(base_ptr + page_size, page_size);
#ifndef HAVE_PAGE_PROTECTION
memcpy(unprotected_ptr + unprotected_size, canary, sizeof canary);
@@ -391,10 +391,10 @@
sodium_malloc(const size_t size)
{
void *ptr;
if ((ptr = _sodium_malloc(size)) == NULL) {
- return NULL;
+ return NULL; /* LCOV_EXCL_LINE */
}
memset(ptr, (int) GARBAGE_VALUE, size);
return ptr;
}