| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/sshbuf.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | static inline int | - | ||||||||||||||||||
| 9 | sshbuf_check_sanity(const struct sshbuf *buf) | - | ||||||||||||||||||
| 10 | { | - | ||||||||||||||||||
| 11 | ; | - | ||||||||||||||||||
| 12 | if (__builtin_expect(((buf ==
| 0-49736721 | ||||||||||||||||||
| 13 | ((void *)0)
| 0-49736721 | ||||||||||||||||||
| 14 | || (!buf->readonly && buf->d != buf->cd) || buf->refcount < 1 || buf->refcount > 0x100000 || buf->cd ==
| 0-49736721 | ||||||||||||||||||
| 15 | ((void *)0)
| 0-49736721 | ||||||||||||||||||
| 16 | || buf->max_size > 0x8000000 || buf->alloc > buf->max_size || buf->size > buf->alloc || buf->off > buf->size) != 0), 0)
| 0-49736721 | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | - | |||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | - | |||||||||||||||||||
| 22 | - | |||||||||||||||||||
| 23 | ) { | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | ; | - | ||||||||||||||||||
| 26 | mysignal( | - | ||||||||||||||||||
| 27 | 11 | - | ||||||||||||||||||
| 28 | , | - | ||||||||||||||||||
| 29 | ((__sighandler_t) 0) | - | ||||||||||||||||||
| 30 | ); | - | ||||||||||||||||||
| 31 | raise( | - | ||||||||||||||||||
| 32 | 11 | - | ||||||||||||||||||
| 33 | ); | - | ||||||||||||||||||
| 34 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||
| 35 | } | - | ||||||||||||||||||
| 36 | return executed 49736721 times by 6 tests: 0;return 0;Executed by:
executed 49736721 times by 6 tests: return 0;Executed by:
| 49736721 | ||||||||||||||||||
| 37 | } | - | ||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | static void | - | ||||||||||||||||||
| 40 | sshbuf_maybe_pack(struct sshbuf *buf, int force) | - | ||||||||||||||||||
| 41 | { | - | ||||||||||||||||||
| 42 | ; | - | ||||||||||||||||||
| 43 | ; | - | ||||||||||||||||||
| 44 | if (buf->off == 0
| 0-9797402 | ||||||||||||||||||
| 45 | return; executed 9797402 times by 6 tests: return;Executed by:
| 9797402 | ||||||||||||||||||
| 46 | if (force
| 16536-45548 | ||||||||||||||||||
| 47 | (buf->off >= 8192
| 0-45436 | ||||||||||||||||||
| 48 | memmove(buf->d, buf->d + buf->off, buf->size - buf->off); | - | ||||||||||||||||||
| 49 | buf->size -= buf->off; | - | ||||||||||||||||||
| 50 | buf->off = 0; | - | ||||||||||||||||||
| 51 | ; | - | ||||||||||||||||||
| 52 | } executed 16648 times by 1 test: end of blockExecuted by:
| 16648 | ||||||||||||||||||
| 53 | } executed 62084 times by 1 test: end of blockExecuted by:
| 62084 | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | struct sshbuf * | - | ||||||||||||||||||
| 56 | sshbuf_new(void) | - | ||||||||||||||||||
| 57 | { | - | ||||||||||||||||||
| 58 | struct sshbuf *ret; | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | if ((
| 0-2058693 | ||||||||||||||||||
| 61 | ((void *)0)
| 0-2058693 | ||||||||||||||||||
| 62 | ) | - | ||||||||||||||||||
| 63 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 64 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 65 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 66 | ret->alloc = 256; | - | ||||||||||||||||||
| 67 | ret->max_size = 0x8000000; | - | ||||||||||||||||||
| 68 | ret->readonly = 0; | - | ||||||||||||||||||
| 69 | ret->refcount = 1; | - | ||||||||||||||||||
| 70 | ret->parent = | - | ||||||||||||||||||
| 71 | ((void *)0) | - | ||||||||||||||||||
| 72 | ; | - | ||||||||||||||||||
| 73 | if ((
| 0-2058693 | ||||||||||||||||||
| 74 | ((void *)0)
| 0-2058693 | ||||||||||||||||||
| 75 | ) { | - | ||||||||||||||||||
| 76 | free(ret); | - | ||||||||||||||||||
| 77 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 78 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 79 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 80 | } | - | ||||||||||||||||||
| 81 | return executed 2058693 times by 6 tests: ret;return ret;Executed by:
executed 2058693 times by 6 tests: return ret;Executed by:
| 2058693 | ||||||||||||||||||
| 82 | } | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | struct sshbuf * | - | ||||||||||||||||||
| 85 | sshbuf_from(const void *blob, size_t len) | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | struct sshbuf *ret; | - | ||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | if (blob ==
| 0-265205 | ||||||||||||||||||
| 90 | ((void *)0)
| 0-265205 | ||||||||||||||||||
| 91 | || len > 0x8000000
| 0-265205 | ||||||||||||||||||
| 92 | (
| 0-265205 | ||||||||||||||||||
| 93 | ((void *)0)
| 0-265205 | ||||||||||||||||||
| 94 | ) | - | ||||||||||||||||||
| 95 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 96 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 97 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 98 | ret->alloc = ret->size = ret->max_size = len; | - | ||||||||||||||||||
| 99 | ret->readonly = 1; | - | ||||||||||||||||||
| 100 | ret->refcount = 1; | - | ||||||||||||||||||
| 101 | ret->parent = | - | ||||||||||||||||||
| 102 | ((void *)0) | - | ||||||||||||||||||
| 103 | ; | - | ||||||||||||||||||
| 104 | ret->cd = blob; | - | ||||||||||||||||||
| 105 | ret->d = | - | ||||||||||||||||||
| 106 | ((void *)0) | - | ||||||||||||||||||
| 107 | ; | - | ||||||||||||||||||
| 108 | return executed 265205 times by 6 tests: ret;return ret;Executed by:
executed 265205 times by 6 tests: return ret;Executed by:
| 265205 | ||||||||||||||||||
| 109 | } | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | int | - | ||||||||||||||||||
| 112 | sshbuf_set_parent(struct sshbuf *child, struct sshbuf *parent) | - | ||||||||||||||||||
| 113 | { | - | ||||||||||||||||||
| 114 | int r; | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | if ((
| 0-132747 | ||||||||||||||||||
| 117 | (
| 0-132747 | ||||||||||||||||||
| 118 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 119 | child->parent = parent; | - | ||||||||||||||||||
| 120 | child->parent->refcount++; | - | ||||||||||||||||||
| 121 | return executed 132747 times by 6 tests: 0;return 0;Executed by:
executed 132747 times by 6 tests: return 0;Executed by:
| 132747 | ||||||||||||||||||
| 122 | } | - | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | struct sshbuf * | - | ||||||||||||||||||
| 125 | sshbuf_fromb(struct sshbuf *buf) | - | ||||||||||||||||||
| 126 | { | - | ||||||||||||||||||
| 127 | struct sshbuf *ret; | - | ||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | if (sshbuf_check_sanity(buf) != 0
| 0-43764 | ||||||||||||||||||
| 130 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 131 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 132 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 133 | if ((
| 0-43764 | ||||||||||||||||||
| 134 | ((void *)0)
| 0-43764 | ||||||||||||||||||
| 135 | ) | - | ||||||||||||||||||
| 136 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 137 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 138 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 139 | if (sshbuf_set_parent(ret, buf) != 0
| 0-43764 | ||||||||||||||||||
| 140 | sshbuf_free(ret); | - | ||||||||||||||||||
| 141 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 142 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 143 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 144 | } | - | ||||||||||||||||||
| 145 | return executed 43764 times by 6 tests: ret;return ret;Executed by:
executed 43764 times by 6 tests: return ret;Executed by:
| 43764 | ||||||||||||||||||
| 146 | } | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | void | - | ||||||||||||||||||
| 149 | sshbuf_free(struct sshbuf *buf) | - | ||||||||||||||||||
| 150 | { | - | ||||||||||||||||||
| 151 | if (buf ==
| 2456643-2564902 | ||||||||||||||||||
| 152 | ((void *)0)
| 2456643-2564902 | ||||||||||||||||||
| 153 | ) | - | ||||||||||||||||||
| 154 | return; executed 2564902 times by 6 tests: return;Executed by:
| 2564902 | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | - | |||||||||||||||||||
| 159 | - | |||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | if (sshbuf_check_sanity(buf) != 0
| 0-2456643 | ||||||||||||||||||
| 162 | return; never executed: return; | 0 | ||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | sshbuf_free(buf->parent); | - | ||||||||||||||||||
| 168 | buf->parent = | - | ||||||||||||||||||
| 169 | ((void *)0) | - | ||||||||||||||||||
| 170 | ; | - | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | - | |||||||||||||||||||
| 173 | - | |||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | buf->refcount--; | - | ||||||||||||||||||
| 177 | if (buf->refcount > 0
| 132747-2323896 | ||||||||||||||||||
| 178 | return; executed 132747 times by 6 tests: return;Executed by:
| 132747 | ||||||||||||||||||
| 179 | if (!buf->readonly
| 265205-2058691 | ||||||||||||||||||
| 180 | explicit_bzero(buf->d, buf->alloc); | - | ||||||||||||||||||
| 181 | free(buf->d); | - | ||||||||||||||||||
| 182 | } executed 2058691 times by 6 tests: end of blockExecuted by:
| 2058691 | ||||||||||||||||||
| 183 | explicit_bzero(buf, sizeof(*buf)); | - | ||||||||||||||||||
| 184 | free(buf); | - | ||||||||||||||||||
| 185 | } executed 2323896 times by 6 tests: end of blockExecuted by:
| 2323896 | ||||||||||||||||||
| 186 | - | |||||||||||||||||||
| 187 | void | - | ||||||||||||||||||
| 188 | sshbuf_reset(struct sshbuf *buf) | - | ||||||||||||||||||
| 189 | { | - | ||||||||||||||||||
| 190 | u_char *d; | - | ||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | if (buf->readonly
| 0-258629 | ||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | buf->off = buf->size; | - | ||||||||||||||||||
| 195 | return; never executed: return; | 0 | ||||||||||||||||||
| 196 | } | - | ||||||||||||||||||
| 197 | (void) sshbuf_check_sanity(buf); | - | ||||||||||||||||||
| 198 | buf->off = buf->size = 0; | - | ||||||||||||||||||
| 199 | if (buf->alloc != 256
| 31252-227377 | ||||||||||||||||||
| 200 | if ((
| 0-227377 | ||||||||||||||||||
| 201 | 1)) !=
| 0-227377 | ||||||||||||||||||
| 202 | ((void *)0)
| 0-227377 | ||||||||||||||||||
| 203 | ) { | - | ||||||||||||||||||
| 204 | buf->cd = buf->d = d; | - | ||||||||||||||||||
| 205 | buf->alloc = 256; | - | ||||||||||||||||||
| 206 | } executed 227377 times by 4 tests: end of blockExecuted by:
| 227377 | ||||||||||||||||||
| 207 | } executed 227377 times by 4 tests: end of blockExecuted by:
| 227377 | ||||||||||||||||||
| 208 | explicit_bzero(buf->d, 256); | - | ||||||||||||||||||
| 209 | } executed 258629 times by 5 tests: end of blockExecuted by:
| 258629 | ||||||||||||||||||
| 210 | - | |||||||||||||||||||
| 211 | size_t | - | ||||||||||||||||||
| 212 | sshbuf_max_size(const struct sshbuf *buf) | - | ||||||||||||||||||
| 213 | { | - | ||||||||||||||||||
| 214 | return executed 315020 times by 1 test: buf->max_size;return buf->max_size;Executed by:
executed 315020 times by 1 test: return buf->max_size;Executed by:
| 315020 | ||||||||||||||||||
| 215 | } | - | ||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | size_t | - | ||||||||||||||||||
| 218 | sshbuf_alloc(const struct sshbuf *buf) | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | return executed 1 time by 1 test: buf->alloc;return buf->alloc;Executed by:
executed 1 time by 1 test: return buf->alloc;Executed by:
| 1 | ||||||||||||||||||
| 221 | } | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | const struct sshbuf * | - | ||||||||||||||||||
| 224 | sshbuf_parent(const struct sshbuf *buf) | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | return executed 3 times by 1 test: buf->parent;return buf->parent;Executed by:
executed 3 times by 1 test: return buf->parent;Executed by:
| 3 | ||||||||||||||||||
| 227 | } | - | ||||||||||||||||||
| 228 | - | |||||||||||||||||||
| 229 | u_int | - | ||||||||||||||||||
| 230 | sshbuf_refcount(const struct sshbuf *buf) | - | ||||||||||||||||||
| 231 | { | - | ||||||||||||||||||
| 232 | return executed 3 times by 1 test: buf->refcount;return buf->refcount;Executed by:
executed 3 times by 1 test: return buf->refcount;Executed by:
| 3 | ||||||||||||||||||
| 233 | } | - | ||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | int | - | ||||||||||||||||||
| 236 | sshbuf_set_max_size(struct sshbuf *buf, size_t max_size) | - | ||||||||||||||||||
| 237 | { | - | ||||||||||||||||||
| 238 | size_t rlen; | - | ||||||||||||||||||
| 239 | u_char *dp; | - | ||||||||||||||||||
| 240 | int r; | - | ||||||||||||||||||
| 241 | - | |||||||||||||||||||
| 242 | ; | - | ||||||||||||||||||
| 243 | if ((
| 0-26457 | ||||||||||||||||||
| 244 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 245 | if (max_size == buf->max_size
| 1-26456 | ||||||||||||||||||
| 246 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 247 | if (buf->readonly
| 0-26455 | ||||||||||||||||||
| 248 | return executed 1 time by 1 test: -49;return -49;Executed by:
executed 1 time by 1 test: return -49;Executed by:
| 1 | ||||||||||||||||||
| 249 | if (max_size > 0x8000000
| 0-26455 | ||||||||||||||||||
| 250 | return never executed: -9;return -9;never executed: return -9; | 0 | ||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | sshbuf_maybe_pack(buf, max_size < buf->size); | - | ||||||||||||||||||
| 253 | if (max_size < buf->alloc
| 5581-15829 | ||||||||||||||||||
| 254 | if (buf->size < 256
| 197-5384 | ||||||||||||||||||
| 255 | rlen = 256; executed 197 times by 1 test: rlen = 256;Executed by:
| 197 | ||||||||||||||||||
| 256 | else | - | ||||||||||||||||||
| 257 | rlen = ((((buf->size)+((256)-1))/(256))*(256)); executed 5384 times by 1 test: rlen = ((((buf->size)+((256)-1))/(256))*(256));Executed by:
| 5384 | ||||||||||||||||||
| 258 | if (rlen > max_size
| 379-5202 | ||||||||||||||||||
| 259 | rlen = max_size; executed 379 times by 1 test: rlen = max_size;Executed by:
| 379 | ||||||||||||||||||
| 260 | ; | - | ||||||||||||||||||
| 261 | if ((
| 0-5581 | ||||||||||||||||||
| 262 | ((void *)0)
| 0-5581 | ||||||||||||||||||
| 263 | ) | - | ||||||||||||||||||
| 264 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 265 | buf->cd = buf->d = dp; | - | ||||||||||||||||||
| 266 | buf->alloc = rlen; | - | ||||||||||||||||||
| 267 | } executed 5581 times by 1 test: end of blockExecuted by:
| 5581 | ||||||||||||||||||
| 268 | ; | - | ||||||||||||||||||
| 269 | if (max_size < buf->alloc
| 10248-16207 | ||||||||||||||||||
| 270 | return executed 10248 times by 1 test: -9;return -9;Executed by:
executed 10248 times by 1 test: return -9;Executed by:
| 10248 | ||||||||||||||||||
| 271 | buf->max_size = max_size; | - | ||||||||||||||||||
| 272 | return executed 16207 times by 1 test: 0;return 0;Executed by:
executed 16207 times by 1 test: return 0;Executed by:
| 16207 | ||||||||||||||||||
| 273 | } | - | ||||||||||||||||||
| 274 | - | |||||||||||||||||||
| 275 | size_t | - | ||||||||||||||||||
| 276 | sshbuf_len(const struct sshbuf *buf) | - | ||||||||||||||||||
| 277 | { | - | ||||||||||||||||||
| 278 | if (sshbuf_check_sanity(buf) != 0
| 0-16980196 | ||||||||||||||||||
| 279 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 280 | return executed 16980196 times by 6 tests: buf->size - buf->off;return buf->size - buf->off;Executed by:
executed 16980196 times by 6 tests: return buf->size - buf->off;Executed by:
| 16980196 | ||||||||||||||||||
| 281 | } | - | ||||||||||||||||||
| 282 | - | |||||||||||||||||||
| 283 | size_t | - | ||||||||||||||||||
| 284 | sshbuf_avail(const struct sshbuf *buf) | - | ||||||||||||||||||
| 285 | { | - | ||||||||||||||||||
| 286 | if (sshbuf_check_sanity(buf) != 0
| 0-471423 | ||||||||||||||||||
| 287 | return executed 1 time by 1 test: 0;return 0;Executed by:
executed 1 time by 1 test: return 0;Executed by:
| 1 | ||||||||||||||||||
| 288 | return executed 471422 times by 1 test: buf->max_size - (buf->size - buf->off);return buf->max_size - (buf->size - buf->off);Executed by:
executed 471422 times by 1 test: return buf->max_size - (buf->size - buf->off);Executed by:
| 471422 | ||||||||||||||||||
| 289 | } | - | ||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | const u_char * | - | ||||||||||||||||||
| 292 | sshbuf_ptr(const struct sshbuf *buf) | - | ||||||||||||||||||
| 293 | { | - | ||||||||||||||||||
| 294 | if (sshbuf_check_sanity(buf) != 0
| 0-11919937 | ||||||||||||||||||
| 295 | return never executed: return ((void *)0) ;never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 296 | ((void *)0) never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 297 | ; never executed: return ((void *)0) ; | 0 | ||||||||||||||||||
| 298 | return executed 11919937 times by 6 tests: buf->cd + buf->off;return buf->cd + buf->off;Executed by:
executed 11919937 times by 6 tests: return buf->cd + buf->off;Executed by:
| 11919937 | ||||||||||||||||||
| 299 | } | - | ||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | u_char * | - | ||||||||||||||||||
| 302 | sshbuf_mutable_ptr(const struct sshbuf *buf) | - | ||||||||||||||||||
| 303 | { | - | ||||||||||||||||||
| 304 | if (sshbuf_check_sanity(buf) != 0
| 0-1386 | ||||||||||||||||||
| 305 | return executed 3 times by 1 test: return ((void *)0) ;Executed by:
executed 3 times by 1 test: return ((void *)0) ;Executed by:
| 3 | ||||||||||||||||||
| 306 | ((void *)0) executed 3 times by 1 test: return ((void *)0) ;Executed by:
| 3 | ||||||||||||||||||
| 307 | ; executed 3 times by 1 test: return ((void *)0) ;Executed by:
| 3 | ||||||||||||||||||
| 308 | return executed 1383 times by 4 tests: buf->d + buf->off;return buf->d + buf->off;Executed by:
executed 1383 times by 4 tests: return buf->d + buf->off;Executed by:
| 1383 | ||||||||||||||||||
| 309 | } | - | ||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | int | - | ||||||||||||||||||
| 312 | sshbuf_check_reserve(const struct sshbuf *buf, size_t len) | - | ||||||||||||||||||
| 313 | { | - | ||||||||||||||||||
| 314 | int r; | - | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | if ((
| 0-10164853 | ||||||||||||||||||
| 317 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 318 | if (buf->readonly
| 0-10164850 | ||||||||||||||||||
| 319 | return executed 3 times by 1 test: -49;return -49;Executed by:
executed 3 times by 1 test: return -49;Executed by:
| 3 | ||||||||||||||||||
| 320 | ; | - | ||||||||||||||||||
| 321 | - | |||||||||||||||||||
| 322 | if (len > buf->max_size
| 19512-10135545 | ||||||||||||||||||
| 323 | return executed 48817 times by 1 test: -9;return -9;Executed by:
executed 48817 times by 1 test: return -9;Executed by:
| 48817 | ||||||||||||||||||
| 324 | return executed 10116033 times by 6 tests: 0;return 0;Executed by:
executed 10116033 times by 6 tests: return 0;Executed by:
| 10116033 | ||||||||||||||||||
| 325 | } | - | ||||||||||||||||||
| 326 | - | |||||||||||||||||||
| 327 | int | - | ||||||||||||||||||
| 328 | sshbuf_allocate(struct sshbuf *buf, size_t len) | - | ||||||||||||||||||
| 329 | { | - | ||||||||||||||||||
| 330 | size_t rlen, need; | - | ||||||||||||||||||
| 331 | u_char *dp; | - | ||||||||||||||||||
| 332 | int r; | - | ||||||||||||||||||
| 333 | - | |||||||||||||||||||
| 334 | ; | - | ||||||||||||||||||
| 335 | if ((
| 48819-9833031 | ||||||||||||||||||
| 336 | return executed 48819 times by 1 test: r;return r;Executed by:
executed 48819 times by 1 test: return r;Executed by:
| 48819 | ||||||||||||||||||
| 337 | - | |||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | - | |||||||||||||||||||
| 341 | sshbuf_maybe_pack(buf, buf->size + len > buf->max_size); | - | ||||||||||||||||||
| 342 | ; | - | ||||||||||||||||||
| 343 | if (len + buf->size <= buf->alloc
| 283002-9550029 | ||||||||||||||||||
| 344 | return executed 9550029 times by 6 tests: 0;return 0;Executed by:
executed 9550029 times by 6 tests: return 0;Executed by:
| 9550029 | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | - | |||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | need = len + buf->size - buf->alloc; | - | ||||||||||||||||||
| 351 | rlen = ((((buf->alloc + need)+((256)-1))/(256))*(256)); | - | ||||||||||||||||||
| 352 | ; | - | ||||||||||||||||||
| 353 | if (rlen > buf->max_size
| 1385-281617 | ||||||||||||||||||
| 354 | rlen = buf->alloc + need; executed 1385 times by 1 test: rlen = buf->alloc + need;Executed by:
| 1385 | ||||||||||||||||||
| 355 | ; | - | ||||||||||||||||||
| 356 | if ((
| 0-283002 | ||||||||||||||||||
| 357 | ((void *)0)
| 0-283002 | ||||||||||||||||||
| 358 | ) { | - | ||||||||||||||||||
| 359 | ; | - | ||||||||||||||||||
| 360 | return never executed: -2;return -2;never executed: return -2; | 0 | ||||||||||||||||||
| 361 | } | - | ||||||||||||||||||
| 362 | buf->alloc = rlen; | - | ||||||||||||||||||
| 363 | buf->cd = buf->d = dp; | - | ||||||||||||||||||
| 364 | if ((
| 0-283002 | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 367 | } | - | ||||||||||||||||||
| 368 | ; | - | ||||||||||||||||||
| 369 | return executed 283002 times by 6 tests: 0;return 0;Executed by:
executed 283002 times by 6 tests: return 0;Executed by:
| 283002 | ||||||||||||||||||
| 370 | } | - | ||||||||||||||||||
| 371 | - | |||||||||||||||||||
| 372 | int | - | ||||||||||||||||||
| 373 | sshbuf_reserve(struct sshbuf *buf, size_t len, u_char **dpp) | - | ||||||||||||||||||
| 374 | { | - | ||||||||||||||||||
| 375 | u_char *dp; | - | ||||||||||||||||||
| 376 | int r; | - | ||||||||||||||||||
| 377 | - | |||||||||||||||||||
| 378 | if (dpp !=
| 4-9881846 | ||||||||||||||||||
| 379 | ((void *)0)
| 4-9881846 | ||||||||||||||||||
| 380 | ) | - | ||||||||||||||||||
| 381 | * executed 9881846 times by 6 tests: dpp = *dpp = ((void *)0) ;Executed by:
executed 9881846 times by 6 tests: *dpp = ((void *)0) ;Executed by:
| 9881846 | ||||||||||||||||||
| 382 | ((void *)0) executed 9881846 times by 6 tests: *dpp = ((void *)0) ;Executed by:
| 9881846 | ||||||||||||||||||
| 383 | ; executed 9881846 times by 6 tests: *dpp = ((void *)0) ;Executed by:
| 9881846 | ||||||||||||||||||
| 384 | - | |||||||||||||||||||
| 385 | ; | - | ||||||||||||||||||
| 386 | if ((
| 48819-9833031 | ||||||||||||||||||
| 387 | return executed 48819 times by 1 test: r;return r;Executed by:
executed 48819 times by 1 test: return r;Executed by:
| 48819 | ||||||||||||||||||
| 388 | - | |||||||||||||||||||
| 389 | dp = buf->d + buf->size; | - | ||||||||||||||||||
| 390 | buf->size += len; | - | ||||||||||||||||||
| 391 | if (dpp !=
| 3-9833028 | ||||||||||||||||||
| 392 | ((void *)0)
| 3-9833028 | ||||||||||||||||||
| 393 | ) | - | ||||||||||||||||||
| 394 | * executed 9833028 times by 6 tests: dpp = dp;*dpp = dp;Executed by:
executed 9833028 times by 6 tests: *dpp = dp;Executed by:
| 9833028 | ||||||||||||||||||
| 395 | return executed 9833031 times by 6 tests: 0;return 0;Executed by:
executed 9833031 times by 6 tests: return 0;Executed by:
| 9833031 | ||||||||||||||||||
| 396 | } | - | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | int | - | ||||||||||||||||||
| 399 | sshbuf_consume(struct sshbuf *buf, size_t len) | - | ||||||||||||||||||
| 400 | { | - | ||||||||||||||||||
| 401 | int r; | - | ||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | ; | - | ||||||||||||||||||
| 404 | if ((
| 0-7081632 | ||||||||||||||||||
| 405 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 406 | if (len == 0
| 1295-7080337 | ||||||||||||||||||
| 407 | return executed 1295 times by 2 tests: 0;return 0;Executed by:
executed 1295 times by 2 tests: return 0;Executed by:
| 1295 | ||||||||||||||||||
| 408 | if (len > sshbuf_len(buf)
| 7059-7073278 | ||||||||||||||||||
| 409 | return executed 7059 times by 2 tests: -3;return -3;Executed by:
executed 7059 times by 2 tests: return -3;Executed by:
| 7059 | ||||||||||||||||||
| 410 | buf->off += len; | - | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | if (buf->off == buf->size
| 167940-6905338 | ||||||||||||||||||
| 413 | buf->off = buf->size = 0; executed 167940 times by 6 tests: buf->off = buf->size = 0;Executed by:
| 167940 | ||||||||||||||||||
| 414 | ; | - | ||||||||||||||||||
| 415 | return executed 7073278 times by 6 tests: 0;return 0;Executed by:
executed 7073278 times by 6 tests: return 0;Executed by:
| 7073278 | ||||||||||||||||||
| 416 | } | - | ||||||||||||||||||
| 417 | - | |||||||||||||||||||
| 418 | int | - | ||||||||||||||||||
| 419 | sshbuf_consume_end(struct sshbuf *buf, size_t len) | - | ||||||||||||||||||
| 420 | { | - | ||||||||||||||||||
| 421 | int r; | - | ||||||||||||||||||
| 422 | - | |||||||||||||||||||
| 423 | ; | - | ||||||||||||||||||
| 424 | if ((
| 0-66307 | ||||||||||||||||||
| 425 | return never executed: r;return r;never executed: return r; | 0 | ||||||||||||||||||
| 426 | if (len == 0
| 1335-64972 | ||||||||||||||||||
| 427 | return executed 1335 times by 1 test: 0;return 0;Executed by:
executed 1335 times by 1 test: return 0;Executed by:
| 1335 | ||||||||||||||||||
| 428 | if (len > sshbuf_len(buf)
| 7040-57932 | ||||||||||||||||||
| 429 | return executed 7040 times by 1 test: -3;return -3;Executed by:
executed 7040 times by 1 test: return -3;Executed by:
| 7040 | ||||||||||||||||||
| 430 | buf->size -= len; | - | ||||||||||||||||||
| 431 | ; | - | ||||||||||||||||||
| 432 | return executed 57932 times by 4 tests: 0;return 0;Executed by:
executed 57932 times by 4 tests: return 0;Executed by:
| 57932 | ||||||||||||||||||
| 433 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |