OpenCoverage

xmalloc.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/xmalloc.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9void-
10ssh_malloc_init(void)-
11{-
12-
13-
14-
15-
16-
17}-
18-
19void *-
20xmalloc(size_t size)-
21{-
22 void *ptr;-
23-
24 if (size == 0
size == 0Description
TRUEnever evaluated
FALSEevaluated 7981 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
)
0-7981
25 fatal("xmalloc: zero size");
never executed: fatal("xmalloc: zero size");
0
26 ptr = malloc(size);-
27 if (ptr ==
ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7981 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
0-7981
28 ((void *)0)
ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 7981 times by 4 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
0-7981
29 )-
30 fatal("xmalloc: out of memory (allocating %zu bytes)", size);
never executed: fatal("xmalloc: out of memory (allocating %zu bytes)", size);
0
31 return
executed 7981 times by 4 tests: return ptr;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
ptr;
executed 7981 times by 4 tests: return ptr;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
7981
32}-
33-
34void *-
35xcalloc(size_t nmemb, size_t size)-
36{-
37 void *ptr;-
38-
39 if (size == 0
size == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
|| nmemb == 0
nmemb == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
)
0-10
40 fatal("xcalloc: zero size");
never executed: fatal("xcalloc: zero size");
0
41 if (-
42 (
(1844674407370.../ nmemb < sizeDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
18446744073709551615UL)
(1844674407370.../ nmemb < sizeDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
0-10
43 / nmemb < size
(1844674407370.../ nmemb < sizeDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
)
0-10
44 fatal("xcalloc: nmemb * size > SIZE_MAX");
never executed: fatal("xcalloc: nmemb * size > SIZE_MAX");
0
45 ptr = calloc(nmemb, size);-
46 if (ptr ==
ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
0-10
47 ((void *)0)
ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • sshd
0-10
48 )-
49 fatal("xcalloc: out of memory (allocating %zu bytes)",
never executed: fatal("xcalloc: out of memory (allocating %zu bytes)", size * nmemb);
0
50 size * nmemb);
never executed: fatal("xcalloc: out of memory (allocating %zu bytes)", size * nmemb);
0
51 return
executed 10 times by 1 test: return ptr;
Executed by:
  • sshd
ptr;
executed 10 times by 1 test: return ptr;
Executed by:
  • sshd
10
52}-
53-
54void *-
55xreallocarray(void *ptr, size_t nmemb, size_t size)-
56{-
57 void *new_ptr;-
58-
59 new_ptr = reallocarray(ptr, nmemb, size);-
60 if (new_ptr ==
new_ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ssh-keygen
0-1
61 ((void *)0)
new_ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • ssh-keygen
0-1
62 )-
63 fatal("xreallocarray: out of memory (%zu elements of %zu bytes)",
never executed: fatal("xreallocarray: out of memory (%zu elements of %zu bytes)", nmemb, size);
0
64 nmemb, size);
never executed: fatal("xreallocarray: out of memory (%zu elements of %zu bytes)", nmemb, size);
0
65 return
executed 1 time by 1 test: return new_ptr;
Executed by:
  • ssh-keygen
new_ptr;
executed 1 time by 1 test: return new_ptr;
Executed by:
  • ssh-keygen
1
66}-
67-
68void *-
69xrecallocarray(void *ptr, size_t onmemb, size_t nmemb, size_t size)-
70{-
71 void *new_ptr;-
72-
73 new_ptr = recallocarray(ptr, onmemb, nmemb, size);-
74 if (new_ptr ==
new_ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • sshd
0-14
75 ((void *)0)
new_ptr == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • sshd
0-14
76 )-
77 fatal("xrecallocarray: out of memory (%zu elements of %zu bytes)",
never executed: fatal("xrecallocarray: out of memory (%zu elements of %zu bytes)", nmemb, size);
0
78 nmemb, size);
never executed: fatal("xrecallocarray: out of memory (%zu elements of %zu bytes)", nmemb, size);
0
79 return
executed 14 times by 1 test: return new_ptr;
Executed by:
  • sshd
new_ptr;
executed 14 times by 1 test: return new_ptr;
Executed by:
  • sshd
14
80}-
81-
82char *-
83xstrdup(const char *str)-
84{-
85 size_t len;-
86 char *cp;-
87-
88 len = strlen(str) + 1;-
89 cp = xmalloc(len);-
90 strlcpy(cp, str, len);-
91 return
executed 7563 times by 4 tests: return cp;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
cp;
executed 7563 times by 4 tests: return cp;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
7563
92}-
93-
94int-
95xasprintf(char **ret, const char *fmt, ...)-
96{-
97 va_list ap;-
98 int i;-
99-
100 -
101__builtin_va_start(-
102ap-
103,-
104fmt-
105)-
106 ;-
107 i = vasprintf(ret, fmt, ap);-
108 -
109__builtin_va_end(-
110ap-
111)-
112 ;-
113-
114 if (i < 0
i < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| *
*ret == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
ret ==
*ret == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
115 ((void *)0)
*ret == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
116 )-
117 fatal("xasprintf: could not allocate memory");
never executed: fatal("xasprintf: could not allocate memory");
0
118-
119 return
never executed: return (i);
(i);
never executed: return (i);
0
120}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2