| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/bio/bf_buff.c | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | static int buffer_write(BIO *h, const char *buf, int num); | - | ||||||||||||||||||||||||
| 4 | static int buffer_read(BIO *h, char *buf, int size); | - | ||||||||||||||||||||||||
| 5 | static int buffer_puts(BIO *h, const char *str); | - | ||||||||||||||||||||||||
| 6 | static int buffer_gets(BIO *h, char *str, int size); | - | ||||||||||||||||||||||||
| 7 | static long buffer_ctrl(BIO *h, int cmd, long arg1, void *arg2); | - | ||||||||||||||||||||||||
| 8 | static int buffer_new(BIO *h); | - | ||||||||||||||||||||||||
| 9 | static int buffer_free(BIO *data); | - | ||||||||||||||||||||||||
| 10 | static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); | - | ||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||
| 13 | static const BIO_METHOD methods_buffer = { | - | ||||||||||||||||||||||||
| 14 | .type = (9|0x0200), | - | ||||||||||||||||||||||||
| 15 | .name = "buffer", | - | ||||||||||||||||||||||||
| 16 | .bwrite = buffer_write, | - | ||||||||||||||||||||||||
| 17 | .bread = buffer_read, | - | ||||||||||||||||||||||||
| 18 | .bputs = buffer_puts, | - | ||||||||||||||||||||||||
| 19 | .bgets = buffer_gets, | - | ||||||||||||||||||||||||
| 20 | .ctrl = buffer_ctrl, | - | ||||||||||||||||||||||||
| 21 | .create = buffer_new, | - | ||||||||||||||||||||||||
| 22 | .destroy = buffer_free, | - | ||||||||||||||||||||||||
| 23 | .callback_ctrl = buffer_callback_ctrl | - | ||||||||||||||||||||||||
| 24 | }; | - | ||||||||||||||||||||||||
| 25 | - | |||||||||||||||||||||||||
| 26 | const BIO_METHOD * | - | ||||||||||||||||||||||||
| 27 | BIO_f_buffer(void) | - | ||||||||||||||||||||||||
| 28 | { | - | ||||||||||||||||||||||||
| 29 | return executed 142 times by 5 tests: (&methods_buffer); return (&methods_buffer);Executed by: 
 executed 142 times by 5 tests:  return (&methods_buffer);Executed by: 
 | 142 | ||||||||||||||||||||||||
| 30 | } | - | ||||||||||||||||||||||||
| 31 | - | |||||||||||||||||||||||||
| 32 | static int | - | ||||||||||||||||||||||||
| 33 | buffer_new(BIO *bi) | - | ||||||||||||||||||||||||
| 34 | { | - | ||||||||||||||||||||||||
| 35 | BIO_F_BUFFER_CTX *ctx; | - | ||||||||||||||||||||||||
| 36 | - | |||||||||||||||||||||||||
| 37 | ctx = malloc(sizeof(BIO_F_BUFFER_CTX)); | - | ||||||||||||||||||||||||
| 38 | if (ctx == 
 | 0-142 | ||||||||||||||||||||||||
| 39 | ((void *)0) 
 | 0-142 | ||||||||||||||||||||||||
| 40 | ) | - | ||||||||||||||||||||||||
| 41 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 42 | ctx->ibuf = malloc(4096); | - | ||||||||||||||||||||||||
| 43 | if (ctx->ibuf == 
 | 0-142 | ||||||||||||||||||||||||
| 44 | ((void *)0) 
 | 0-142 | ||||||||||||||||||||||||
| 45 | ) { | - | ||||||||||||||||||||||||
| 46 | free(ctx); | - | ||||||||||||||||||||||||
| 47 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 48 | } | - | ||||||||||||||||||||||||
| 49 | ctx->obuf = malloc(4096); | - | ||||||||||||||||||||||||
| 50 | if (ctx->obuf == 
 | 0-142 | ||||||||||||||||||||||||
| 51 | ((void *)0) 
 | 0-142 | ||||||||||||||||||||||||
| 52 | ) { | - | ||||||||||||||||||||||||
| 53 | free(ctx->ibuf); | - | ||||||||||||||||||||||||
| 54 | free(ctx); | - | ||||||||||||||||||||||||
| 55 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 56 | } | - | ||||||||||||||||||||||||
| 57 | ctx->ibuf_size = 4096; | - | ||||||||||||||||||||||||
| 58 | ctx->obuf_size = 4096; | - | ||||||||||||||||||||||||
| 59 | ctx->ibuf_len = 0; | - | ||||||||||||||||||||||||
| 60 | ctx->ibuf_off = 0; | - | ||||||||||||||||||||||||
| 61 | ctx->obuf_len = 0; | - | ||||||||||||||||||||||||
| 62 | ctx->obuf_off = 0; | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | bi->init = 1; | - | ||||||||||||||||||||||||
| 65 | bi->ptr = (char *)ctx; | - | ||||||||||||||||||||||||
| 66 | bi->flags = 0; | - | ||||||||||||||||||||||||
| 67 | return executed 142 times by 5 tests: (1); return (1);Executed by: 
 executed 142 times by 5 tests:  return (1);Executed by: 
 | 142 | ||||||||||||||||||||||||
| 68 | } | - | ||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||
| 70 | static int | - | ||||||||||||||||||||||||
| 71 | buffer_free(BIO *a) | - | ||||||||||||||||||||||||
| 72 | { | - | ||||||||||||||||||||||||
| 73 | BIO_F_BUFFER_CTX *b; | - | ||||||||||||||||||||||||
| 74 | - | |||||||||||||||||||||||||
| 75 | if (a == 
 | 0-142 | ||||||||||||||||||||||||
| 76 | ((void *)0) 
 | 0-142 | ||||||||||||||||||||||||
| 77 | ) | - | ||||||||||||||||||||||||
| 78 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 79 | b = (BIO_F_BUFFER_CTX *)a->ptr; | - | ||||||||||||||||||||||||
| 80 | free(b->ibuf); | - | ||||||||||||||||||||||||
| 81 | free(b->obuf); | - | ||||||||||||||||||||||||
| 82 | free(a->ptr); | - | ||||||||||||||||||||||||
| 83 | a->ptr = | - | ||||||||||||||||||||||||
| 84 | ((void *)0) | - | ||||||||||||||||||||||||
| 85 | ; | - | ||||||||||||||||||||||||
| 86 | a->init = 0; | - | ||||||||||||||||||||||||
| 87 | a->flags = 0; | - | ||||||||||||||||||||||||
| 88 | return executed 142 times by 5 tests: (1); return (1);Executed by: 
 executed 142 times by 5 tests:  return (1);Executed by: 
 | 142 | ||||||||||||||||||||||||
| 89 | } | - | ||||||||||||||||||||||||
| 90 | - | |||||||||||||||||||||||||
| 91 | static int | - | ||||||||||||||||||||||||
| 92 | buffer_read(BIO *b, char *out, int outl) | - | ||||||||||||||||||||||||
| 93 | { | - | ||||||||||||||||||||||||
| 94 | int i, num = 0; | - | ||||||||||||||||||||||||
| 95 | BIO_F_BUFFER_CTX *ctx; | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | if (out == 
 | 0 | ||||||||||||||||||||||||
| 98 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 99 | ) | - | ||||||||||||||||||||||||
| 100 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 101 | ctx = (BIO_F_BUFFER_CTX *)b->ptr; | - | ||||||||||||||||||||||||
| 102 | - | |||||||||||||||||||||||||
| 103 | if (( 
 
 | 0 | ||||||||||||||||||||||||
| 104 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 105 | ) 
 
 
 | 0 | ||||||||||||||||||||||||
| 106 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 107 | ) 
 | 0 | ||||||||||||||||||||||||
| 108 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 109 | num = 0; | - | ||||||||||||||||||||||||
| 110 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 111 | - | |||||||||||||||||||||||||
| 112 | start: code before this statement never executed:  start: | 0 | ||||||||||||||||||||||||
| 113 | i = ctx->ibuf_len; | - | ||||||||||||||||||||||||
| 114 | - | |||||||||||||||||||||||||
| 115 | if (i != 0 
 | 0 | ||||||||||||||||||||||||
| 116 | if (i > outl 
 | 0 | ||||||||||||||||||||||||
| 117 | i = outl; never executed:  i = outl; | 0 | ||||||||||||||||||||||||
| 118 | memcpy(out, &(ctx->ibuf[ctx->ibuf_off]), i); | - | ||||||||||||||||||||||||
| 119 | ctx->ibuf_off += i; | - | ||||||||||||||||||||||||
| 120 | ctx->ibuf_len -= i; | - | ||||||||||||||||||||||||
| 121 | num += i; | - | ||||||||||||||||||||||||
| 122 | if (outl == i 
 | 0 | ||||||||||||||||||||||||
| 123 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 124 | outl -= i; | - | ||||||||||||||||||||||||
| 125 | out += i; | - | ||||||||||||||||||||||||
| 126 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||
| 133 | if (outl > ctx->ibuf_size 
 | 0 | ||||||||||||||||||||||||
| 134 | for (;;) { | - | ||||||||||||||||||||||||
| 135 | i = BIO_read(b->next_bio, out, outl); | - | ||||||||||||||||||||||||
| 136 | if (i <= 0 
 | 0 | ||||||||||||||||||||||||
| 137 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 138 | if (i < 0 
 | 0 | ||||||||||||||||||||||||
| 139 | return never executed: (( return ((num > 0) ? num : i);
 
 never executed:  return ((num > 0) ? num : i); | 0 | ||||||||||||||||||||||||
| 140 | if (i == 0 
 | 0 | ||||||||||||||||||||||||
| 141 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 142 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 143 | num += i; | - | ||||||||||||||||||||||||
| 144 | if (outl == i 
 | 0 | ||||||||||||||||||||||||
| 145 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 146 | out += i; | - | ||||||||||||||||||||||||
| 147 | outl -= i; | - | ||||||||||||||||||||||||
| 148 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 149 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 150 | - | |||||||||||||||||||||||||
| 151 | - | |||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||
| 153 | i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size); | - | ||||||||||||||||||||||||
| 154 | if (i <= 0 
 | 0 | ||||||||||||||||||||||||
| 155 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 156 | if (i < 0 
 | 0 | ||||||||||||||||||||||||
| 157 | return never executed: (( return ((num > 0) ? num : i);
 
 never executed:  return ((num > 0) ? num : i); | 0 | ||||||||||||||||||||||||
| 158 | if (i == 0 
 | 0 | ||||||||||||||||||||||||
| 159 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 160 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 161 | ctx->ibuf_off = 0; | - | ||||||||||||||||||||||||
| 162 | ctx->ibuf_len = i; | - | ||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | - | |||||||||||||||||||||||||
| 165 | goto never executed: start; goto start;never executed:  goto start; | 0 | ||||||||||||||||||||||||
| 166 | } | - | ||||||||||||||||||||||||
| 167 | - | |||||||||||||||||||||||||
| 168 | static int | - | ||||||||||||||||||||||||
| 169 | buffer_write(BIO *b, const char *in, int inl) | - | ||||||||||||||||||||||||
| 170 | { | - | ||||||||||||||||||||||||
| 171 | int i, num = 0; | - | ||||||||||||||||||||||||
| 172 | BIO_F_BUFFER_CTX *ctx; | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | if (( 
 
 | 0-687 | ||||||||||||||||||||||||
| 175 | ((void *)0) 
 | 0-687 | ||||||||||||||||||||||||
| 176 | ) 
 
 
 | 0-687 | ||||||||||||||||||||||||
| 177 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 178 | ctx = (BIO_F_BUFFER_CTX *)b->ptr; | - | ||||||||||||||||||||||||
| 179 | if (( 
 
 | 0-687 | ||||||||||||||||||||||||
| 180 | ((void *)0) 
 | 0-687 | ||||||||||||||||||||||||
| 181 | ) 
 
 
 | 0-687 | ||||||||||||||||||||||||
| 182 | ((void *)0) 
 | 0-687 | ||||||||||||||||||||||||
| 183 | ) 
 | 0-687 | ||||||||||||||||||||||||
| 184 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 185 | - | |||||||||||||||||||||||||
| 186 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 187 | start: code before this statement executed 687 times by 4 tests:  start:Executed by: 
 | 687 | ||||||||||||||||||||||||
| 188 | i = ctx->obuf_size - (ctx->obuf_len + ctx->obuf_off); | - | ||||||||||||||||||||||||
| 189 | - | |||||||||||||||||||||||||
| 190 | if (i >= inl 
 | 0-687 | ||||||||||||||||||||||||
| 191 | memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, inl); | - | ||||||||||||||||||||||||
| 192 | ctx->obuf_len += inl; | - | ||||||||||||||||||||||||
| 193 | return executed 687 times by 4 tests: (num + inl); return (num + inl);Executed by: 
 executed 687 times by 4 tests:  return (num + inl);Executed by: 
 | 687 | ||||||||||||||||||||||||
| 194 | } | - | ||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||
| 196 | - | |||||||||||||||||||||||||
| 197 | if (ctx->obuf_len != 0 
 | 0 | ||||||||||||||||||||||||
| 198 | if (i > 0 
 | 0 | ||||||||||||||||||||||||
| 199 | { | - | ||||||||||||||||||||||||
| 200 | memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, i); | - | ||||||||||||||||||||||||
| 201 | in += i; | - | ||||||||||||||||||||||||
| 202 | inl -= i; | - | ||||||||||||||||||||||||
| 203 | num += i; | - | ||||||||||||||||||||||||
| 204 | ctx->obuf_len += i; | - | ||||||||||||||||||||||||
| 205 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | for (;;) { | - | ||||||||||||||||||||||||
| 208 | i = BIO_write(b->next_bio, &(ctx->obuf[ctx->obuf_off]), | - | ||||||||||||||||||||||||
| 209 | ctx->obuf_len); | - | ||||||||||||||||||||||||
| 210 | if (i <= 0 
 | 0 | ||||||||||||||||||||||||
| 211 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 212 | - | |||||||||||||||||||||||||
| 213 | if (i < 0 
 | 0 | ||||||||||||||||||||||||
| 214 | return never executed: (( return ((num > 0) ? num : i);
 
 never executed:  return ((num > 0) ? num : i); | 0 | ||||||||||||||||||||||||
| 215 | if (i == 0 
 | 0 | ||||||||||||||||||||||||
| 216 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 217 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 218 | ctx->obuf_off += i; | - | ||||||||||||||||||||||||
| 219 | ctx->obuf_len -= i; | - | ||||||||||||||||||||||||
| 220 | if (ctx->obuf_len == 0 
 | 0 | ||||||||||||||||||||||||
| 221 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 222 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 223 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 224 | - | |||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | ctx->obuf_off = 0; | - | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | - | |||||||||||||||||||||||||
| 229 | while (inl >= ctx->obuf_size 
 | 0 | ||||||||||||||||||||||||
| 230 | i = BIO_write(b->next_bio, in, inl); | - | ||||||||||||||||||||||||
| 231 | if (i <= 0 
 | 0 | ||||||||||||||||||||||||
| 232 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 233 | if (i < 0 
 | 0 | ||||||||||||||||||||||||
| 234 | return never executed: (( return ((num > 0) ? num : i);
 
 never executed:  return ((num > 0) ? num : i); | 0 | ||||||||||||||||||||||||
| 235 | if (i == 0 
 | 0 | ||||||||||||||||||||||||
| 236 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 237 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 238 | num += i; | - | ||||||||||||||||||||||||
| 239 | in += i; | - | ||||||||||||||||||||||||
| 240 | inl -= i; | - | ||||||||||||||||||||||||
| 241 | if (inl == 0 
 | 0 | ||||||||||||||||||||||||
| 242 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 243 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||
| 246 | - | |||||||||||||||||||||||||
| 247 | goto never executed: start; goto start;never executed:  goto start; | 0 | ||||||||||||||||||||||||
| 248 | } | - | ||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | static long | - | ||||||||||||||||||||||||
| 251 | buffer_ctrl(BIO *b, int cmd, long num, void *ptr) | - | ||||||||||||||||||||||||
| 252 | { | - | ||||||||||||||||||||||||
| 253 | BIO *dbio; | - | ||||||||||||||||||||||||
| 254 | BIO_F_BUFFER_CTX *ctx; | - | ||||||||||||||||||||||||
| 255 | long ret = 1; | - | ||||||||||||||||||||||||
| 256 | char *p1, *p2; | - | ||||||||||||||||||||||||
| 257 | int r, i, *ip; | - | ||||||||||||||||||||||||
| 258 | int ibs, obs; | - | ||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||
| 260 | ctx = (BIO_F_BUFFER_CTX *)b->ptr; | - | ||||||||||||||||||||||||
| 261 | - | |||||||||||||||||||||||||
| 262 | switch (cmd) { | - | ||||||||||||||||||||||||
| 263 | case executed 139 times by 4 tests: 1: case 1:Executed by: 
 executed 139 times by 4 tests:  case 1:Executed by: 
 | 139 | ||||||||||||||||||||||||
| 264 | ctx->ibuf_off = 0; | - | ||||||||||||||||||||||||
| 265 | ctx->ibuf_len = 0; | - | ||||||||||||||||||||||||
| 266 | ctx->obuf_off = 0; | - | ||||||||||||||||||||||||
| 267 | ctx->obuf_len = 0; | - | ||||||||||||||||||||||||
| 268 | if (b->next_bio == 
 | 0-139 | ||||||||||||||||||||||||
| 269 | ((void *)0) 
 | 0-139 | ||||||||||||||||||||||||
| 270 | ) | - | ||||||||||||||||||||||||
| 271 | return executed 139 times by 4 tests: (0); return (0);Executed by: 
 executed 139 times by 4 tests:  return (0);Executed by: 
 | 139 | ||||||||||||||||||||||||
| 272 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 273 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 274 | case never executed: 3: case 3:never executed:  case 3: | 0 | ||||||||||||||||||||||||
| 275 | ret = (long)ctx->obuf_len; | - | ||||||||||||||||||||||||
| 276 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 277 | case never executed: 116: case 116:never executed:  case 116: | 0 | ||||||||||||||||||||||||
| 278 | ret = 0; | - | ||||||||||||||||||||||||
| 279 | p1 = ctx->ibuf; | - | ||||||||||||||||||||||||
| 280 | for (i = 0; i < ctx->ibuf_len 
 | 0 | ||||||||||||||||||||||||
| 281 | if (p1[ctx->ibuf_off + i] == '\n' 
 | 0 | ||||||||||||||||||||||||
| 282 | ret++; never executed:  ret++; | 0 | ||||||||||||||||||||||||
| 283 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 284 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 285 | case executed 120 times by 1 test: 13: case 13:Executed by: 
 executed 120 times by 1 test:  case 13:Executed by: 
 | 120 | ||||||||||||||||||||||||
| 286 | ret = (long)ctx->obuf_len; | - | ||||||||||||||||||||||||
| 287 | if (ret == 0 
 | 33-87 | ||||||||||||||||||||||||
| 288 | if (b->next_bio == 
 | 0-33 | ||||||||||||||||||||||||
| 289 | ((void *)0) 
 | 0-33 | ||||||||||||||||||||||||
| 290 | ) | - | ||||||||||||||||||||||||
| 291 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 292 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 293 | } executed 33 times by 1 test:  end of blockExecuted by: 
 | 33 | ||||||||||||||||||||||||
| 294 | break; executed 120 times by 1 test:  break;Executed by: 
 | 120 | ||||||||||||||||||||||||
| 295 | case never executed: 10: case 10:never executed:  case 10: | 0 | ||||||||||||||||||||||||
| 296 | ret = (long)ctx->ibuf_len; | - | ||||||||||||||||||||||||
| 297 | if (ret == 0 
 | 0 | ||||||||||||||||||||||||
| 298 | if (b->next_bio == 
 | 0 | ||||||||||||||||||||||||
| 299 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 300 | ) | - | ||||||||||||||||||||||||
| 301 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 302 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 303 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 304 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 305 | case never executed: 122: case 122:never executed:  case 122: | 0 | ||||||||||||||||||||||||
| 306 | if (num > ctx->ibuf_size 
 | 0 | ||||||||||||||||||||||||
| 307 | p1 = malloc(num); | - | ||||||||||||||||||||||||
| 308 | if (p1 == 
 | 0 | ||||||||||||||||||||||||
| 309 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 310 | ) | - | ||||||||||||||||||||||||
| 311 | goto never executed: malloc_error; goto malloc_error;never executed:  goto malloc_error; | 0 | ||||||||||||||||||||||||
| 312 | free(ctx->ibuf); | - | ||||||||||||||||||||||||
| 313 | ctx->ibuf = p1; | - | ||||||||||||||||||||||||
| 314 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 315 | ctx->ibuf_off = 0; | - | ||||||||||||||||||||||||
| 316 | ctx->ibuf_len = (int)num; | - | ||||||||||||||||||||||||
| 317 | memcpy(ctx->ibuf, ptr, num); | - | ||||||||||||||||||||||||
| 318 | ret = 1; | - | ||||||||||||||||||||||||
| 319 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 320 | case executed 139 times by 4 tests: 117: case 117:Executed by: 
 executed 139 times by 4 tests:  case 117:Executed by: 
 | 139 | ||||||||||||||||||||||||
| 321 | if (ptr != 
 | 0-139 | ||||||||||||||||||||||||
| 322 | ((void *)0) 
 | 0-139 | ||||||||||||||||||||||||
| 323 | ) { | - | ||||||||||||||||||||||||
| 324 | ip = (int *)ptr; | - | ||||||||||||||||||||||||
| 325 | if (* 
 
 | 0-139 | ||||||||||||||||||||||||
| 326 | ibs = (int)num; | - | ||||||||||||||||||||||||
| 327 | obs = ctx->obuf_size; | - | ||||||||||||||||||||||||
| 328 | } executed 139 times by 4 tests:  end of blockExecuted by: 
 | 139 | ||||||||||||||||||||||||
| 329 | else | - | ||||||||||||||||||||||||
| 330 | { | - | ||||||||||||||||||||||||
| 331 | ibs = ctx->ibuf_size; | - | ||||||||||||||||||||||||
| 332 | obs = (int)num; | - | ||||||||||||||||||||||||
| 333 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 334 | } else { | - | ||||||||||||||||||||||||
| 335 | ibs = (int)num; | - | ||||||||||||||||||||||||
| 336 | obs = (int)num; | - | ||||||||||||||||||||||||
| 337 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 338 | p1 = ctx->ibuf; | - | ||||||||||||||||||||||||
| 339 | p2 = ctx->obuf; | - | ||||||||||||||||||||||||
| 340 | if (( 
 
 
 
 | 0-139 | ||||||||||||||||||||||||
| 341 | p1 = malloc(num); | - | ||||||||||||||||||||||||
| 342 | if (p1 == 
 | 0 | ||||||||||||||||||||||||
| 343 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 344 | ) | - | ||||||||||||||||||||||||
| 345 | goto never executed: malloc_error; goto malloc_error;never executed:  goto malloc_error; | 0 | ||||||||||||||||||||||||
| 346 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 347 | if (( 
 
 
 
 | 0-139 | ||||||||||||||||||||||||
| 348 | p2 = malloc(num); | - | ||||||||||||||||||||||||
| 349 | if (p2 == 
 | 0 | ||||||||||||||||||||||||
| 350 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 351 | ) { | - | ||||||||||||||||||||||||
| 352 | if (p1 != ctx->ibuf 
 | 0 | ||||||||||||||||||||||||
| 353 | free(p1); never executed:  free(p1); | 0 | ||||||||||||||||||||||||
| 354 | goto never executed: malloc_error; goto malloc_error;never executed:  goto malloc_error; | 0 | ||||||||||||||||||||||||
| 355 | } | - | ||||||||||||||||||||||||
| 356 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 357 | if (ctx->ibuf != p1 
 | 0-139 | ||||||||||||||||||||||||
| 358 | free(ctx->ibuf); | - | ||||||||||||||||||||||||
| 359 | ctx->ibuf = p1; | - | ||||||||||||||||||||||||
| 360 | ctx->ibuf_off = 0; | - | ||||||||||||||||||||||||
| 361 | ctx->ibuf_len = 0; | - | ||||||||||||||||||||||||
| 362 | ctx->ibuf_size = ibs; | - | ||||||||||||||||||||||||
| 363 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 364 | if (ctx->obuf != p2 
 | 0-139 | ||||||||||||||||||||||||
| 365 | free(ctx->obuf); | - | ||||||||||||||||||||||||
| 366 | ctx->obuf = p2; | - | ||||||||||||||||||||||||
| 367 | ctx->obuf_off = 0; | - | ||||||||||||||||||||||||
| 368 | ctx->obuf_len = 0; | - | ||||||||||||||||||||||||
| 369 | ctx->obuf_size = obs; | - | ||||||||||||||||||||||||
| 370 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 371 | break; executed 139 times by 4 tests:  break;Executed by: 
 | 139 | ||||||||||||||||||||||||
| 372 | case never executed: 101: case 101:never executed:  case 101: | 0 | ||||||||||||||||||||||||
| 373 | if (b->next_bio == 
 | 0 | ||||||||||||||||||||||||
| 374 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 375 | ) | - | ||||||||||||||||||||||||
| 376 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 377 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 378 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 379 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 380 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||
| 382 | case executed 581 times by 4 tests: 11: case 11:Executed by: 
 executed 581 times by 4 tests:  case 11:Executed by: 
 | 581 | ||||||||||||||||||||||||
| 383 | if (b->next_bio == 
 | 0-581 | ||||||||||||||||||||||||
| 384 | ((void *)0) 
 | 0-581 | ||||||||||||||||||||||||
| 385 | ) | - | ||||||||||||||||||||||||
| 386 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 387 | if (ctx->obuf_len <= 0 
 | 0-581 | ||||||||||||||||||||||||
| 388 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 389 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 390 | } | - | ||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||
| 392 | for (;;) { | - | ||||||||||||||||||||||||
| 393 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 394 | if (ctx->obuf_len > 0 
 | 205-771 | ||||||||||||||||||||||||
| 395 | r = BIO_write(b->next_bio, | - | ||||||||||||||||||||||||
| 396 | &(ctx->obuf[ctx->obuf_off]), | - | ||||||||||||||||||||||||
| 397 | ctx->obuf_len); | - | ||||||||||||||||||||||||
| 398 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 399 | if (r <= 0 
 | 376-395 | ||||||||||||||||||||||||
| 400 | return executed 376 times by 2 tests: ((long)r); return ((long)r);Executed by: 
 executed 376 times by 2 tests:  return ((long)r);Executed by: 
 | 376 | ||||||||||||||||||||||||
| 401 | ctx->obuf_off += r; | - | ||||||||||||||||||||||||
| 402 | ctx->obuf_len -= r; | - | ||||||||||||||||||||||||
| 403 | } executed 395 times by 4 tests: else { end of blockExecuted by: 
 | 395 | ||||||||||||||||||||||||
| 404 | ctx->obuf_len = 0; | - | ||||||||||||||||||||||||
| 405 | ctx->obuf_off = 0; | - | ||||||||||||||||||||||||
| 406 | break; executed 205 times by 4 tests:  break;Executed by: 
 | 205 | ||||||||||||||||||||||||
| 407 | } | - | ||||||||||||||||||||||||
| 408 | } | - | ||||||||||||||||||||||||
| 409 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 410 | break; executed 205 times by 4 tests:  break;Executed by: 
 | 205 | ||||||||||||||||||||||||
| 411 | case never executed: 12: case 12:never executed:  case 12: | 0 | ||||||||||||||||||||||||
| 412 | dbio = (BIO *)ptr; | - | ||||||||||||||||||||||||
| 413 | if (!BIO_int_ctrl(dbio,117,ctx->ibuf_size,0) 
 | 0 | ||||||||||||||||||||||||
| 414 | !BIO_int_ctrl(dbio,117,ctx->obuf_size,1) 
 | 0 | ||||||||||||||||||||||||
| 415 | ret = 0; never executed:  ret = 0; | 0 | ||||||||||||||||||||||||
| 416 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 417 | default executed 306 times by 5 tests: : default:Executed by: 
 executed 306 times by 5 tests:  default:Executed by: 
 | 306 | ||||||||||||||||||||||||
| 418 | if (b->next_bio == 
 | 0-306 | ||||||||||||||||||||||||
| 419 | ((void *)0) 
 | 0-306 | ||||||||||||||||||||||||
| 420 | ) | - | ||||||||||||||||||||||||
| 421 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 422 | ret = BIO_ctrl(b->next_bio, cmd, num, ptr); | - | ||||||||||||||||||||||||
| 423 | break; executed 306 times by 5 tests:  break;Executed by: 
 | 306 | ||||||||||||||||||||||||
| 424 | } | - | ||||||||||||||||||||||||
| 425 | return executed 770 times by 5 tests: (ret); return (ret);Executed by: 
 executed 770 times by 5 tests:  return (ret);Executed by: 
 | 770 | ||||||||||||||||||||||||
| 426 | malloc_error: | - | ||||||||||||||||||||||||
| 427 | ERR_put_error(32,(0xfff),((1|64)),__FILE__,448); | - | ||||||||||||||||||||||||
| 428 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 429 | } | - | ||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||
| 431 | static long | - | ||||||||||||||||||||||||
| 432 | buffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) | - | ||||||||||||||||||||||||
| 433 | { | - | ||||||||||||||||||||||||
| 434 | long ret = 1; | - | ||||||||||||||||||||||||
| 435 | - | |||||||||||||||||||||||||
| 436 | if (b->next_bio == 
 | 0 | ||||||||||||||||||||||||
| 437 | ((void *)0) 
 | 0 | ||||||||||||||||||||||||
| 438 | ) | - | ||||||||||||||||||||||||
| 439 | return never executed: (0); return (0);never executed:  return (0); | 0 | ||||||||||||||||||||||||
| 440 | switch (cmd) { | - | ||||||||||||||||||||||||
| 441 | default never executed: : default:never executed:  default: | 0 | ||||||||||||||||||||||||
| 442 | ret = BIO_callback_ctrl(b->next_bio, cmd, fp); | - | ||||||||||||||||||||||||
| 443 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 444 | } | - | ||||||||||||||||||||||||
| 445 | return never executed: (ret); return (ret);never executed:  return (ret); | 0 | ||||||||||||||||||||||||
| 446 | } | - | ||||||||||||||||||||||||
| 447 | - | |||||||||||||||||||||||||
| 448 | static int | - | ||||||||||||||||||||||||
| 449 | buffer_gets(BIO *b, char *buf, int size) | - | ||||||||||||||||||||||||
| 450 | { | - | ||||||||||||||||||||||||
| 451 | BIO_F_BUFFER_CTX *ctx; | - | ||||||||||||||||||||||||
| 452 | int num = 0, i, flag; | - | ||||||||||||||||||||||||
| 453 | char *p; | - | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | ctx = (BIO_F_BUFFER_CTX *)b->ptr; | - | ||||||||||||||||||||||||
| 456 | size--; | - | ||||||||||||||||||||||||
| 457 | BIO_clear_flags(b, ((0x01|0x02|0x04)|0x08)); | - | ||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | for (;;) { | - | ||||||||||||||||||||||||
| 460 | if (ctx->ibuf_len > 0 
 | 0 | ||||||||||||||||||||||||
| 461 | p = &(ctx->ibuf[ctx->ibuf_off]); | - | ||||||||||||||||||||||||
| 462 | flag = 0; | - | ||||||||||||||||||||||||
| 463 | for (i = 0; ( 
 
 
 
 | 0 | ||||||||||||||||||||||||
| 464 | *(buf++) = p[i]; | - | ||||||||||||||||||||||||
| 465 | if (p[i] == '\n' 
 | 0 | ||||||||||||||||||||||||
| 466 | flag = 1; | - | ||||||||||||||||||||||||
| 467 | i++; | - | ||||||||||||||||||||||||
| 468 | break; never executed:  break; | 0 | ||||||||||||||||||||||||
| 469 | } | - | ||||||||||||||||||||||||
| 470 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 471 | num += i; | - | ||||||||||||||||||||||||
| 472 | size -= i; | - | ||||||||||||||||||||||||
| 473 | ctx->ibuf_len -= i; | - | ||||||||||||||||||||||||
| 474 | ctx->ibuf_off += i; | - | ||||||||||||||||||||||||
| 475 | if (flag 
 
 | 0 | ||||||||||||||||||||||||
| 476 | *buf = '\0'; | - | ||||||||||||||||||||||||
| 477 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 478 | } | - | ||||||||||||||||||||||||
| 479 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 480 | else | - | ||||||||||||||||||||||||
| 481 | { | - | ||||||||||||||||||||||||
| 482 | i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size); | - | ||||||||||||||||||||||||
| 483 | if (i <= 0 
 | 0 | ||||||||||||||||||||||||
| 484 | BIO_copy_next_retry(b); | - | ||||||||||||||||||||||||
| 485 | *buf = '\0'; | - | ||||||||||||||||||||||||
| 486 | if (i < 0 
 | 0 | ||||||||||||||||||||||||
| 487 | return never executed: (( return ((num > 0) ? num : i);
 
 never executed:  return ((num > 0) ? num : i); | 0 | ||||||||||||||||||||||||
| 488 | if (i == 0 
 | 0 | ||||||||||||||||||||||||
| 489 | return never executed: (num); return (num);never executed:  return (num); | 0 | ||||||||||||||||||||||||
| 490 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 491 | ctx->ibuf_len = i; | - | ||||||||||||||||||||||||
| 492 | ctx->ibuf_off = 0; | - | ||||||||||||||||||||||||
| 493 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 494 | } | - | ||||||||||||||||||||||||
| 495 | } never executed:  end of block | 0 | ||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||
| 497 | static int | - | ||||||||||||||||||||||||
| 498 | buffer_puts(BIO *b, const char *str) | - | ||||||||||||||||||||||||
| 499 | { | - | ||||||||||||||||||||||||
| 500 | return never executed: (buffer_write(b, str, strlen(str))); return (buffer_write(b, str, strlen(str)));never executed:  return (buffer_write(b, str, strlen(str))); | 0 | ||||||||||||||||||||||||
| 501 | } | - | ||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |