OpenCoverage

sshbuf-getput-basic.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/sshbuf-getput-basic.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* $OpenBSD: sshbuf-getput-basic.c,v 1.7 2017/06/01 04:51:58 djm Exp $ */-
2/*-
3 * Copyright (c) 2011 Damien Miller-
4 *-
5 * Permission to use, copy, modify, and distribute this software for any-
6 * purpose with or without fee is hereby granted, provided that the above-
7 * copyright notice and this permission notice appear in all copies.-
8 *-
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES-
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF-
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR-
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES-
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN-
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF-
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.-
16 */-
17-
18#define SSHBUF_INTERNAL-
19#include "includes.h"-
20-
21#include <sys/types.h>-
22-
23#include <stdarg.h>-
24#include <stdlib.h>-
25#include <stdio.h>-
26#include <string.h>-
27-
28#include "ssherr.h"-
29#include "sshbuf.h"-
30-
31int-
32sshbuf_get(struct sshbuf *buf, void *v, size_t len)-
33{-
34 const u_char *p = sshbuf_ptr(buf);-
35 int r;-
36-
37 if ((r = sshbuf_consume(buf, len)) < 0)
(r = sshbuf_co...buf, len)) < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 65 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
1-65
38 return r;
executed 1 time by 1 test: return r;
Executed by:
  • test_sshbuf
1
39 if (v != NULL && len != 0)
v != ((void *)0)Description
TRUEevaluated 65 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEnever evaluated
len != 0Description
TRUEevaluated 33 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEevaluated 32 times by 1 test
Evaluated by:
  • test_kex
0-65
40 memcpy(v, p, len);
executed 33 times by 2 tests: memcpy(v, p, len);
Executed by:
  • test_kex
  • test_sshbuf
33
41 return 0;
executed 65 times by 2 tests: return 0;
Executed by:
  • test_kex
  • test_sshbuf
65
42}-
43-
44int-
45sshbuf_get_u64(struct sshbuf *buf, u_int64_t *valp)-
46{-
47 const u_char *p = sshbuf_ptr(buf);-
48 int r;-
49-
50 if ((r = sshbuf_consume(buf, 8)) < 0)
(r = sshbuf_co...e(buf, 8)) < 0Description
TRUEevaluated 97 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 1285256 times by 3 tests
Evaluated by:
  • test_kex
  • test_sshbuf
  • test_sshkey
97-1285256
51 return r;
executed 97 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
97
52 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1285256 times by 3 tests
Evaluated by:
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-1285256
53 *valp = PEEK_U64(p);
executed 1285256 times by 3 tests: *valp = (((u_int64_t)(((const u_char *)(p))[0]) << 56) | ((u_int64_t)(((const u_char *)(p))[1]) << 48) | ((u_int64_t)(((const u_char *)(p))[2]) << 40) | ((u_int64_t)(((const u_char *)(p))[3]) << 32) | ((u_int64_t)(((const u_char *)(p))[4]) << 24) | ((u_int64_t)(((const u_char *)(p))[5]) << 16) | ((u_int64_t)(((const u_char *)(p))[6]) << 8) | (u_int64_t)(((const u_char *)(p))[7]));
Executed by:
  • test_kex
  • test_sshbuf
  • test_sshkey
1285256
54 return 0;
executed 1285256 times by 3 tests: return 0;
Executed by:
  • test_kex
  • test_sshbuf
  • test_sshkey
1285256
55}-
56-
57int-
58sshbuf_get_u32(struct sshbuf *buf, u_int32_t *valp)-
59{-
60 const u_char *p = sshbuf_ptr(buf);-
61 int r;-
62-
63 if ((r = sshbuf_consume(buf, 4)) < 0)
(r = sshbuf_co...e(buf, 4)) < 0Description
TRUEevaluated 18 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 1329270 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
18-1329270
64 return r;
executed 18 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
18
65 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1328950 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 320 times by 1 test
Evaluated by:
  • test_kex
320-1328950
66 *valp = PEEK_U32(p);
executed 1328950 times by 5 tests: *valp = (((u_int32_t)(((const u_char *)(p))[0]) << 24) | ((u_int32_t)(((const u_char *)(p))[1]) << 16) | ((u_int32_t)(((const u_char *)(p))[2]) << 8) | (u_int32_t)(((const u_char *)(p))[3]));
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
1328950
67 return 0;
executed 1329270 times by 5 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
1329270
68}-
69-
70int-
71sshbuf_get_u16(struct sshbuf *buf, u_int16_t *valp)-
72{-
73 const u_char *p = sshbuf_ptr(buf);-
74 int r;-
75-
76 if ((r = sshbuf_consume(buf, 2)) < 0)
(r = sshbuf_co...e(buf, 2)) < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 1239381 times by 1 test
Evaluated by:
  • test_sshbuf
1-1239381
77 return r;
executed 1 time by 1 test: return r;
Executed by:
  • test_sshbuf
1
78 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1239381 times by 1 test
Evaluated by:
  • test_sshbuf
FALSEnever evaluated
0-1239381
79 *valp = PEEK_U16(p);
executed 1239381 times by 1 test: *valp = (((u_int16_t)(((const u_char *)(p))[0]) << 8) | (u_int16_t)(((const u_char *)(p))[1]));
Executed by:
  • test_sshbuf
1239381
80 return 0;
executed 1239381 times by 1 test: return 0;
Executed by:
  • test_sshbuf
1239381
81}-
82-
83int-
84sshbuf_get_u8(struct sshbuf *buf, u_char *valp)-
85{-
86 const u_char *p = sshbuf_ptr(buf);-
87 int r;-
88-
89 if ((r = sshbuf_consume(buf, 1)) < 0)
(r = sshbuf_co...e(buf, 1)) < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 1275242 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
1-1275242
90 return r;
executed 1 time by 1 test: return r;
Executed by:
  • test_sshbuf
1
91 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1269802 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 5440 times by 1 test
Evaluated by:
  • test_kex
5440-1269802
92 *valp = (u_int8_t)*p;
executed 1269802 times by 5 tests: *valp = (u_int8_t)*p;
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
1269802
93 return 0;
executed 1275242 times by 5 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
1275242
94}-
95-
96int-
97sshbuf_get_string(struct sshbuf *buf, u_char **valp, size_t *lenp)-
98{-
99 const u_char *val;-
100 size_t len;-
101 int r;-
102-
103 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1357619 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 3200 times by 1 test
Evaluated by:
  • test_kex
3200-1357619
104 *valp = NULL;
executed 1357619 times by 6 tests: *valp = ((void *)0) ;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1357619
105 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 1357619 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 3200 times by 1 test
Evaluated by:
  • test_kex
3200-1357619
106 *lenp = 0;
executed 1357619 times by 6 tests: *lenp = 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1357619
107 if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0)
(r = sshbuf_ge...al, &len)) < 0Description
TRUEevaluated 4725 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 1356094 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
4725-1356094
108 return r;
executed 4725 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
4725
109 if (valp != NULL) {
valp != ((void *)0)Description
TRUEevaluated 1352894 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 3200 times by 1 test
Evaluated by:
  • test_kex
3200-1352894
110 if ((*valp = malloc(len + 1)) == NULL) {
(*valp = mallo...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 1352894 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
0-1352894
111 SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));-
112 return SSH_ERR_ALLOC_FAIL;
never executed: return -2;
0
113 }-
114 if (len != 0)
len != 0Description
TRUEevaluated 1352820 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 74 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
74-1352820
115 memcpy(*valp, val, len);
executed 1352820 times by 6 tests: memcpy(*valp, val, len);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1352820
116 (*valp)[len] = '\0';-
117 }
executed 1352894 times by 6 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1352894
118 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 1352894 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 3200 times by 1 test
Evaluated by:
  • test_kex
3200-1352894
119 *lenp = len;
executed 1352894 times by 6 tests: *lenp = len;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1352894
120 return 0;
executed 1356094 times by 6 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1356094
121}-
122-
123int-
124sshbuf_get_string_direct(struct sshbuf *buf, const u_char **valp, size_t *lenp)-
125{-
126 size_t len;-
127 const u_char *p;-
128 int r;-
129-
130 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1378046 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 319661 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
319661-1378046
131 *valp = NULL;
executed 1378046 times by 6 tests: *valp = ((void *)0) ;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1378046
132 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 1378046 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 319661 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
319661-1378046
133 *lenp = 0;
executed 1378046 times by 6 tests: *lenp = 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1378046
134 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0)
(r = sshbuf_pe...&p, &len)) < 0Description
TRUEevaluated 6304 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 1691403 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
6304-1691403
135 return r;
executed 6304 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
6304
136 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 1372476 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 318927 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
318927-1372476
137 *valp = p;
executed 1372476 times by 6 tests: *valp = p;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1372476
138 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 1372476 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 318927 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
318927-1372476
139 *lenp = len;
executed 1372476 times by 6 tests: *lenp = len;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1372476
140 if (sshbuf_consume(buf, len + 4) != 0) {
sshbuf_consume... len + 4) != 0Description
TRUEnever evaluated
FALSEevaluated 1691403 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
0-1691403
141 /* Shouldn't happen */-
142 SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));-
143 SSHBUF_ABORT();-
144 return SSH_ERR_INTERNAL_ERROR;
never executed: return -1;
0
145 }-
146 return 0;
executed 1691403 times by 6 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1691403
147}-
148-
149int-
150sshbuf_peek_string_direct(const struct sshbuf *buf, const u_char **valp,-
151 size_t *lenp)-
152{-
153 u_int32_t len;-
154 const u_char *p = sshbuf_ptr(buf);-
155-
156 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 4617117 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
64-4617117
157 *valp = NULL;
executed 4617117 times by 6 tests: *valp = ((void *)0) ;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
4617117
158 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 4617117 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
64-4617117
159 *lenp = 0;
executed 4617117 times by 6 tests: *lenp = 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
4617117
160 if (sshbuf_len(buf) < 4) {
sshbuf_len(buf) < 4Description
TRUEevaluated 343 times by 1 test
Evaluated by:
  • test_sshkey
FALSEevaluated 4616838 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
343-4616838
161 SSHBUF_DBG(("SSH_ERR_MESSAGE_INCOMPLETE"));-
162 return SSH_ERR_MESSAGE_INCOMPLETE;
executed 343 times by 1 test: return -3;
Executed by:
  • test_sshkey
343
163 }-
164 len = PEEK_U32(p);-
165 if (len > SSHBUF_SIZE_MAX - 4) {
len > 0x8000000 - 4Description
TRUEevaluated 2485855 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 2130983 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
2130983-2485855
166 SSHBUF_DBG(("SSH_ERR_STRING_TOO_LARGE"));-
167 return SSH_ERR_STRING_TOO_LARGE;
executed 2485855 times by 2 tests: return -6;
Executed by:
  • test_sshbuf
  • test_sshkey
2485855
168 }-
169 if (sshbuf_len(buf) - 4 < len) {
sshbuf_len(buf) - 4 < lenDescription
TRUEevaluated 15093 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 2115890 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
15093-2115890
170 SSHBUF_DBG(("SSH_ERR_MESSAGE_INCOMPLETE"));-
171 return SSH_ERR_MESSAGE_INCOMPLETE;
executed 15093 times by 2 tests: return -3;
Executed by:
  • test_sshbuf
  • test_sshkey
15093
172 }-
173 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 2115826 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
64-2115826
174 *valp = p + 4;
executed 2115826 times by 6 tests: *valp = p + 4;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
2115826
175 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 2115826 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
64-2115826
176 *lenp = len;
executed 2115826 times by 6 tests: *lenp = len;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
2115826
177 return 0;
executed 2115890 times by 6 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
2115890
178}-
179-
180int-
181sshbuf_get_cstring(struct sshbuf *buf, char **valp, size_t *lenp)-
182{-
183 size_t len;-
184 const u_char *p, *z;-
185 int r;-
186-
187 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 274625 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-274625
188 *valp = NULL;
executed 274625 times by 6 tests: *valp = ((void *)0) ;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
274625
189 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 15534 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 259091 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
15534-259091
190 *lenp = 0;
executed 15534 times by 2 tests: *lenp = 0;
Executed by:
  • test_sshbuf
  • test_sshkey
15534
191 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
(r = sshbuf_pe...p, &len)) != 0Description
TRUEevaluated 11053 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 263572 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
11053-263572
192 return r;
executed 11053 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
11053
193 /* Allow a \0 only at the end of the string */-
194 if (len > 0 &&
len > 0Description
TRUEevaluated 262077 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 1495 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
1495-262077
195 (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) {
(z = memchr(p ...!= ((void *)0)Description
TRUEevaluated 422 times by 3 tests
Evaluated by:
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 261655 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
z < p + len - 1Description
TRUEevaluated 387 times by 3 tests
Evaluated by:
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
FALSEevaluated 35 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
35-261655
196 SSHBUF_DBG(("SSH_ERR_INVALID_FORMAT"));-
197 return SSH_ERR_INVALID_FORMAT;
executed 387 times by 3 tests: return -4;
Executed by:
  • test_hostkeys
  • test_sshbuf
  • test_sshkey
387
198 }-
199 if ((r = sshbuf_skip_string(buf)) != 0)
(r = sshbuf_ge...d *)0) )) != 0Description
TRUEnever evaluated
FALSEevaluated 263185 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
0-263185
200 return -1;
never executed: return -1;
0
201 if (valp != NULL) {
valp != ((void *)0)Description
TRUEevaluated 263185 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-263185
202 if ((*valp = malloc(len + 1)) == NULL) {
(*valp = mallo...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 263185 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
0-263185
203 SSHBUF_DBG(("SSH_ERR_ALLOC_FAIL"));-
204 return SSH_ERR_ALLOC_FAIL;
never executed: return -2;
0
205 }-
206 if (len != 0)
len != 0Description
TRUEevaluated 261690 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 1495 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
1495-261690
207 memcpy(*valp, p, len);
executed 261690 times by 6 tests: memcpy(*valp, p, len);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
261690
208 (*valp)[len] = '\0';-
209 }
executed 263185 times by 6 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
263185
210 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 15350 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 247835 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshkey
15350-247835
211 *lenp = (size_t)len;
executed 15350 times by 2 tests: *lenp = (size_t)len;
Executed by:
  • test_sshbuf
  • test_sshkey
15350
212 return 0;
executed 263185 times by 6 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
263185
213}-
214-
215int-
216sshbuf_get_stringb(struct sshbuf *buf, struct sshbuf *v)-
217{-
218 u_int32_t len;-
219 u_char *p;-
220 int r;-
221-
222 /*-
223 * Use sshbuf_peek_string_direct() to figure out if there is-
224 * a complete string in 'buf' and copy the string directly-
225 * into 'v'.-
226 */-
227 if ((r = sshbuf_peek_string_direct(buf, NULL, NULL)) != 0 ||
(r = sshbuf_pe...d *)0) )) != 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
0-64
228 (r = sshbuf_get_u32(buf, &len)) != 0 ||
(r = sshbuf_ge...f, &len)) != 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
0-64
229 (r = sshbuf_reserve(v, len, &p)) != 0 ||
(r = sshbuf_re...len, &p)) != 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
0-64
230 (r = sshbuf_get(buf, p, len)) != 0)
(r = sshbuf_ge... p, len)) != 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • test_kex
0-64
231 return r;
never executed: return r;
0
232 return 0;
executed 64 times by 1 test: return 0;
Executed by:
  • test_kex
64
233}-
234-
235int-
236sshbuf_put(struct sshbuf *buf, const void *v, size_t len)-
237{-
238 u_char *p;-
239 int r;-
240-
241 if ((r = sshbuf_reserve(buf, len, &p)) < 0)
(r = sshbuf_re... len, &p)) < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 1561867 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1-1561867
242 return r;
executed 1 time by 1 test: return r;
Executed by:
  • test_sshbuf
1
243 if (len != 0)
len != 0Description
TRUEevaluated 1535366 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 26501 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshkey
26501-1535366
244 memcpy(p, v, len);
executed 1535366 times by 6 tests: memcpy(p, v, len);
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1535366
245 return 0;
executed 1561867 times by 6 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1561867
246}-
247-
248int-
249sshbuf_putb(struct sshbuf *buf, const struct sshbuf *v)-
250{-
251 return sshbuf_put(buf, sshbuf_ptr(v), sshbuf_len(v));
executed 42354 times by 3 tests: return sshbuf_put(buf, sshbuf_ptr(v), sshbuf_len(v));
Executed by:
  • test_kex
  • test_sshbuf
  • test_sshkey
42354
252}-
253-
254int-
255sshbuf_putf(struct sshbuf *buf, const char *fmt, ...)-
256{-
257 va_list ap;-
258 int r;-
259-
260 va_start(ap, fmt);-
261 r = sshbuf_putfv(buf, fmt, ap);-
262 va_end(ap);-
263 return r;
executed 12 times by 2 tests: return r;
Executed by:
  • ssh-keygen
  • test_sshbuf
12
264}-
265-
266int-
267sshbuf_putfv(struct sshbuf *buf, const char *fmt, va_list ap)-
268{-
269 va_list ap2;-
270 int r, len;-
271 u_char *p;-
272-
273 VA_COPY(ap2, ap);-
274 if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) {
(len = vsnprin...fmt, ap2)) < 0Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
0-12
275 r = SSH_ERR_INVALID_ARGUMENT;-
276 goto out;
never executed: goto out;
0
277 }-
278 if (len == 0) {
len == 0Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
0-12
279 r = 0;-
280 goto out; /* Nothing to do */
never executed: goto out;
0
281 }-
282 va_end(ap2);-
283 VA_COPY(ap2, ap);-
284 if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0)
(r = sshbuf_re... + 1, &p)) < 0Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
0-12
285 goto out;
never executed: goto out;
0
286 if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) {
(r = vsnprintf..., ap2)) != lenDescription
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
0-12
287 r = SSH_ERR_INTERNAL_ERROR;-
288 goto out; /* Shouldn't happen */
never executed: goto out;
0
289 }-
290 /* Consume terminating \0 */-
291 if ((r = sshbuf_consume_end(buf, 1)) != 0)
(r = sshbuf_co...(buf, 1)) != 0Description
TRUEnever evaluated
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • ssh-keygen
  • test_sshbuf
0-12
292 goto out;
never executed: goto out;
0
293 r = 0;-
294 out:
code before this statement executed 12 times by 2 tests: out:
Executed by:
  • ssh-keygen
  • test_sshbuf
12
295 va_end(ap2);-
296 return r;
executed 12 times by 2 tests: return r;
Executed by:
  • ssh-keygen
  • test_sshbuf
12
297}-
298-
299int-
300sshbuf_put_u64(struct sshbuf *buf, u_int64_t val)-
301{-
302 u_char *p;-
303 int r;-
304-
305 if ((r = sshbuf_reserve(buf, 8, &p)) < 0)
(r = sshbuf_re...f, 8, &p)) < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 168 times by 3 tests
Evaluated by:
  • test_kex
  • test_sshbuf
  • test_sshkey
1-168
306 return r;
executed 1 time by 1 test: return r;
Executed by:
  • test_sshbuf
1
307 POKE_U64(p, val);-
308 return 0;
executed 168 times by 3 tests: return 0;
Executed by:
  • test_kex
  • test_sshbuf
  • test_sshkey
168
309}-
310-
311int-
312sshbuf_put_u32(struct sshbuf *buf, u_int32_t val)-
313{-
314 u_char *p;-
315 int r;-
316-
317 if ((r = sshbuf_reserve(buf, 4, &p)) < 0)
(r = sshbuf_re...f, 4, &p)) < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 1721 times by 4 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshbuf
  • test_sshkey
2-1721
318 return r;
executed 2 times by 1 test: return r;
Executed by:
  • test_sshbuf
2
319 POKE_U32(p, val);-
320 return 0;
executed 1721 times by 4 tests: return 0;
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshbuf
  • test_sshkey
1721
321}-
322-
323int-
324sshbuf_put_u16(struct sshbuf *buf, u_int16_t val)-
325{-
326 u_char *p;-
327 int r;-
328-
329 if ((r = sshbuf_reserve(buf, 2, &p)) < 0)
(r = sshbuf_re...f, 2, &p)) < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 11 times by 1 test
Evaluated by:
  • test_sshbuf
1-11
330 return r;
executed 1 time by 1 test: return r;
Executed by:
  • test_sshbuf
1
331 POKE_U16(p, val);-
332 return 0;
executed 11 times by 1 test: return 0;
Executed by:
  • test_sshbuf
11
333}-
334-
335int-
336sshbuf_put_u8(struct sshbuf *buf, u_char val)-
337{-
338 u_char *p;-
339 int r;-
340-
341 if ((r = sshbuf_reserve(buf, 1, &p)) < 0)
(r = sshbuf_re...f, 1, &p)) < 0Description
TRUEnever evaluated
FALSEevaluated 8185580 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
0-8185580
342 return r;
never executed: return r;
0
343 p[0] = val;-
344 return 0;
executed 8185580 times by 5 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
8185580
345}-
346-
347int-
348sshbuf_put_string(struct sshbuf *buf, const void *v, size_t len)-
349{-
350 u_char *d;-
351 int r;-
352-
353 if (len > SSHBUF_SIZE_MAX - 4) {
len > 0x8000000 - 4Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 6826 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
1-6826
354 SSHBUF_DBG(("SSH_ERR_NO_BUFFER_SPACE"));-
355 return SSH_ERR_NO_BUFFER_SPACE;
executed 1 time by 1 test: return -9;
Executed by:
  • test_sshbuf
1
356 }-
357 if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0)
(r = sshbuf_re... + 4, &d)) < 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 6823 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
3-6823
358 return r;
executed 3 times by 1 test: return r;
Executed by:
  • test_sshbuf
3
359 POKE_U32(d, len);-
360 if (len != 0)
len != 0Description
TRUEevaluated 6330 times by 5 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 493 times by 3 tests
Evaluated by:
  • ssh-keygen
  • test_kex
  • test_sshkey
493-6330
361 memcpy(d + 4, v, len);
executed 6330 times by 5 tests: memcpy(d + 4, v, len);
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
6330
362 return 0;
executed 6823 times by 5 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
6823
363}-
364-
365int-
366sshbuf_put_cstring(struct sshbuf *buf, const char *v)-
367{-
368 return sshbuf_put_string(buf, v, v == NULL ? 0 : strlen(v));
executed 3105 times by 5 tests: return sshbuf_put_string(buf, v, v == ((void *)0) ? 0 : strlen(v));
Executed by:
  • ssh-keygen
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
3105
369}-
370-
371int-
372sshbuf_put_stringb(struct sshbuf *buf, const struct sshbuf *v)-
373{-
374 return sshbuf_put_string(buf, sshbuf_ptr(v), sshbuf_len(v));
executed 279 times by 4 tests: return sshbuf_put_string(buf, sshbuf_ptr(v), sshbuf_len(v));
Executed by:
  • ssh-keygen
  • test_kex
  • test_sshbuf
  • test_sshkey
279
375}-
376-
377int-
378sshbuf_froms(struct sshbuf *buf, struct sshbuf **bufp)-
379{-
380 const u_char *p;-
381 size_t len;-
382 struct sshbuf *ret;-
383 int r;-
384-
385 if (buf == NULL || bufp == NULL)
buf == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 91140 times by 4 tests
Evaluated by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
bufp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 91140 times by 4 tests
Evaluated by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
0-91140
386 return SSH_ERR_INVALID_ARGUMENT;
never executed: return -10;
0
387 *bufp = NULL;-
388 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
(r = sshbuf_pe...p, &len)) != 0Description
TRUEevaluated 2157 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 88983 times by 4 tests
Evaluated by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
2157-88983
389 return r;
executed 2157 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
2157
390 if ((ret = sshbuf_from(p, len)) == NULL)
(ret = sshbuf_...== ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 88983 times by 4 tests
Evaluated by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
0-88983
391 return SSH_ERR_ALLOC_FAIL;
never executed: return -2;
0
392 if ((r = sshbuf_consume(buf, len + 4)) != 0 || /* Shouldn't happen */
(r = sshbuf_co...len + 4)) != 0Description
TRUEnever evaluated
FALSEevaluated 88983 times by 4 tests
Evaluated by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
0-88983
393 (r = sshbuf_set_parent(ret, buf)) != 0) {
(r = sshbuf_se...et, buf)) != 0Description
TRUEnever evaluated
FALSEevaluated 88983 times by 4 tests
Evaluated by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
0-88983
394 sshbuf_free(ret);-
395 return r;
never executed: return r;
0
396 }-
397 *bufp = ret;-
398 return 0;
executed 88983 times by 4 tests: return 0;
Executed by:
  • sshd
  • test_kex
  • test_sshbuf
  • test_sshkey
88983
399}-
400-
401int-
402sshbuf_put_bignum2_bytes(struct sshbuf *buf, const void *v, size_t len)-
403{-
404 u_char *d;-
405 const u_char *s = (const u_char *)v;-
406 int r, prepend;-
407-
408 if (len > SSHBUF_SIZE_MAX - 5) {
len > 0x8000000 - 5Description
TRUEnever evaluated
FALSEevaluated 46 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
0-46
409 SSHBUF_DBG(("SSH_ERR_NO_BUFFER_SPACE"));-
410 return SSH_ERR_NO_BUFFER_SPACE;
never executed: return -9;
0
411 }-
412 /* Skip leading zero bytes */-
413 for (; len > 0 && *s == 0; len--, s++)
len > 0Description
TRUEevaluated 50 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • test_sshbuf
*s == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 44 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
2-50
414 ;
executed 6 times by 1 test: ;
Executed by:
  • test_sshbuf
6
415 /*-
416 * If most significant bit is set then prepend a zero byte to-
417 * avoid interpretation as a negative number.-
418 */-
419 prepend = len > 0 && (s[0] & 0x80) != 0;
len > 0Description
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • test_sshbuf
(s[0] & 0x80) != 0Description
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
2-44
420 if ((r = sshbuf_reserve(buf, len + 4 + prepend, &d)) < 0)
(r = sshbuf_re...pend, &d)) < 0Description
TRUEnever evaluated
FALSEevaluated 46 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
0-46
421 return r;
never executed: return r;
0
422 POKE_U32(d, len + prepend);-
423 if (prepend)
prependDescription
TRUEevaluated 22 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEevaluated 24 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
22-24
424 d[4] = 0;
executed 22 times by 2 tests: d[4] = 0;
Executed by:
  • test_kex
  • test_sshbuf
22
425 if (len != 0)
len != 0Description
TRUEevaluated 44 times by 2 tests
Evaluated by:
  • test_kex
  • test_sshbuf
FALSEevaluated 2 times by 1 test
Evaluated by:
  • test_sshbuf
2-44
426 memcpy(d + 4 + prepend, s, len);
executed 44 times by 2 tests: memcpy(d + 4 + prepend, s, len);
Executed by:
  • test_kex
  • test_sshbuf
44
427 return 0;
executed 46 times by 2 tests: return 0;
Executed by:
  • test_kex
  • test_sshbuf
46
428}-
429-
430int-
431sshbuf_get_bignum2_bytes_direct(struct sshbuf *buf,-
432 const u_char **valp, size_t *lenp)-
433{-
434 const u_char *d;-
435 size_t len, olen;-
436 int r;-
437-
438 if ((r = sshbuf_peek_string_direct(buf, &d, &olen)) < 0)
(r = sshbuf_pe...d, &olen)) < 0Description
TRUEevaluated 1242165 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 65080 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
65080-1242165
439 return r;
executed 1242165 times by 2 tests: return r;
Executed by:
  • test_sshbuf
  • test_sshkey
1242165
440 len = olen;-
441 /* Refuse negative (MSB set) bignums */-
442 if ((len != 0 && (*d & 0x80) != 0))
len != 0Description
TRUEevaluated 65078 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 2 times by 1 test
Evaluated by:
  • test_sshkey
(*d & 0x80) != 0Description
TRUEevaluated 295 times by 2 tests
Evaluated by:
  • test_sshbuf
  • test_sshkey
FALSEevaluated 64783 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
2-65078
443 return SSH_ERR_BIGNUM_IS_NEGATIVE;
executed 295 times by 2 tests: return -5;
Executed by:
  • test_sshbuf
  • test_sshkey
295
444 /* Refuse overlong bignums, allow prepended \0 to avoid MSB set */-
445 if (len > SSHBUF_MAX_BIGNUM + 1 ||
len > (16384 / 8) + 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • test_sshbuf
FALSEevaluated 64784 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
1-64784
446 (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0))
len == (16384 / 8) + 1Description
TRUEnever evaluated
FALSEevaluated 64784 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
*d != 0Description
TRUEnever evaluated
FALSEnever evaluated
0-64784
447 return SSH_ERR_BIGNUM_TOO_LARGE;
executed 1 time by 1 test: return -7;
Executed by:
  • test_sshbuf
1
448 /* Trim leading zeros */-
449 while (len > 0 && *d == 0x00) {
len > 0Description
TRUEevaluated 117796 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 12 times by 1 test
Evaluated by:
  • test_sshkey
*d == 0x00Description
TRUEevaluated 53024 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEevaluated 64772 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
12-117796
450 d++;-
451 len--;-
452 }
executed 53024 times by 6 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
53024
453 if (valp != NULL)
valp != ((void *)0)Description
TRUEevaluated 64784 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-64784
454 *valp = d;
executed 64784 times by 6 tests: *valp = d;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
64784
455 if (lenp != NULL)
lenp != ((void *)0)Description
TRUEevaluated 64784 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
FALSEnever evaluated
0-64784
456 *lenp = len;
executed 64784 times by 6 tests: *lenp = len;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
64784
457 if (sshbuf_consume(buf, olen + 4) != 0) {
sshbuf_consume...olen + 4) != 0Description
TRUEnever evaluated
FALSEevaluated 64784 times by 6 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
0-64784
458 /* Shouldn't happen */-
459 SSHBUF_DBG(("SSH_ERR_INTERNAL_ERROR"));-
460 SSHBUF_ABORT();-
461 return SSH_ERR_INTERNAL_ERROR;
never executed: return -1;
0
462 }-
463 return 0;
executed 64784 times by 6 tests: return 0;
Executed by:
  • ssh-keygen
  • sshd
  • test_hostkeys
  • test_kex
  • test_sshbuf
  • test_sshkey
64784
464}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2