| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | #include "includes.h" | - |
| 21 | #ifndef HAVE_RECALLOCARRAY | - |
| 22 | | - |
| 23 | #include <errno.h> | - |
| 24 | #include <stdlib.h> | - |
| 25 | #ifdef HAVE_STDINT_H | - |
| 26 | #include <stdint.h> | - |
| 27 | #endif | - |
| 28 | #include <string.h> | - |
| 29 | #include <unistd.h> | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | #define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) | - |
| 36 | | - |
| 37 | void * | - |
| 38 | recallocarray(void *ptr, size_t oldnmemb, size_t newnmemb, size_t size) | - |
| 39 | { | - |
| 40 | size_t oldsize, newsize; | - |
| 41 | void *newptr; | - |
| 42 | | - |
| 43 | if (ptr == NULL)| TRUE | evaluated 13386 times by 2 tests | | FALSE | evaluated 529212 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| 13386-529212 |
| 44 | return calloc(newnmemb, size);executed 13386 times by 2 tests: return calloc(newnmemb, size); | 13386 |
| 45 | | - |
| 46 | if ((newnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&| TRUE | never evaluated | | FALSE | evaluated 529212 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| TRUE | never evaluated | | FALSE | evaluated 529212 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-529212 |
| 47 | newnmemb > 0 && SIZE_MAX / newnmemb < size) {| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 48 | errno = ENOMEM; | - |
| 49 | return NULL; never executed: return ((void *)0) ; | 0 |
| 50 | } | - |
| 51 | newsize = newnmemb * size; | - |
| 52 | | - |
| 53 | if ((oldnmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&| TRUE | never evaluated | | FALSE | evaluated 529212 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| TRUE | never evaluated | | FALSE | evaluated 529212 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-529212 |
| 54 | oldnmemb > 0 && SIZE_MAX / oldnmemb < size) {| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 55 | errno = EINVAL; | - |
| 56 | return NULL; never executed: return ((void *)0) ; | 0 |
| 57 | } | - |
| 58 | oldsize = oldnmemb * size; | - |
| 59 | | - |
| 60 | | - |
| 61 | | - |
| 62 | | - |
| 63 | | - |
| 64 | if (newsize <= oldsize) {| TRUE | evaluated 232958 times by 4 testsEvaluated by:- sshd
- test_kex
- test_sshbuf
- test_sshkey
| | FALSE | evaluated 296254 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| 232958-296254 |
| 65 | size_t d = oldsize - newsize; | - |
| 66 | | - |
| 67 | if (d < oldsize / 2 && d < (size_t)getpagesize()) {| TRUE | evaluated 3526 times by 1 test | | FALSE | evaluated 229432 times by 4 testsEvaluated by:- sshd
- test_kex
- test_sshbuf
- test_sshkey
|
| TRUE | evaluated 2409 times by 1 test | | FALSE | evaluated 1117 times by 1 test |
| 1117-229432 |
| 68 | memset((char *)ptr + newsize, 0, d); | - |
| 69 | return ptr;executed 2409 times by 1 test: return ptr; | 2409 |
| 70 | } | - |
| 71 | }executed 230549 times by 4 tests: end of blockExecuted by:- sshd
- test_kex
- test_sshbuf
- test_sshkey
| 230549 |
| 72 | | - |
| 73 | newptr = malloc(newsize); | - |
| 74 | if (newptr == NULL)| TRUE | never evaluated | | FALSE | evaluated 526803 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
|
| 0-526803 |
| 75 | return NULL; never executed: return ((void *)0) ; | 0 |
| 76 | | - |
| 77 | if (newsize > oldsize) {| TRUE | evaluated 296254 times by 8 testsEvaluated by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
| | FALSE | evaluated 230549 times by 4 testsEvaluated by:- sshd
- test_kex
- test_sshbuf
- test_sshkey
|
| 230549-296254 |
| 78 | memcpy(newptr, ptr, oldsize); | - |
| 79 | memset((char *)newptr + oldsize, 0, newsize - oldsize); | - |
| 80 | } elseexecuted 296254 times by 8 tests: end of blockExecuted by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
| 296254 |
| 81 | memcpy(newptr, ptr, newsize);executed 230549 times by 4 tests: memcpy(newptr, ptr, newsize);Executed by:- sshd
- test_kex
- test_sshbuf
- test_sshkey
| 230549 |
| 82 | | - |
| 83 | explicit_bzero(ptr, oldsize); | - |
| 84 | free(ptr); | - |
| 85 | | - |
| 86 | return newptr;executed 526803 times by 8 tests: return newptr;Executed by:- ssh-keygen
- sshd
- test_bitmap
- test_hostkeys
- test_kex
- test_sshbuf
- test_sshkey
- test_utf8
| 526803 |
| 87 | } | - |
| 88 | | - |
| 89 | | - |
| 90 | #endif /* HAVE_RECALLOCARRAY */ | - |
| | |