| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/libressl/src/crypto/asn1/evp_asn1.c | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | int | - | ||||||||||||
| 4 | ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len) | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 | ASN1_STRING *os; | - | ||||||||||||
| 7 | - | |||||||||||||
| 8 |  if ((
 
  | 0-1 | ||||||||||||
| 9 |                                       ((void *)0)
  | 0-1 | ||||||||||||
| 10 | ) | - | ||||||||||||
| 11 |   return never executed:   (0);return (0);never executed:  return (0); | 0 | ||||||||||||
| 12 |  if (!ASN1_STRING_set(os, data, len)
  | 0-1 | ||||||||||||
| 13 | ASN1_OCTET_STRING_free(os); | - | ||||||||||||
| 14 |   return never executed:   (0);return (0);never executed:  return (0); | 0 | ||||||||||||
| 15 | } | - | ||||||||||||
| 16 | ASN1_TYPE_set(a, 4, os); | - | ||||||||||||
| 17 |  return executed 1 time by 1 test:   (1);return (1);Executed by: 
 executed 1 time by 1 test:  return (1);Executed by: 
  | 1 | ||||||||||||
| 18 | } | - | ||||||||||||
| 19 | - | |||||||||||||
| 20 | int | - | ||||||||||||
| 21 | ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len) | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | int ret, num; | - | ||||||||||||
| 24 | unsigned char *p; | - | ||||||||||||
| 25 | - | |||||||||||||
| 26 |  if ((
 
  | 0-1 | ||||||||||||
| 27 |      (
 
  | 0-1 | ||||||||||||
| 28 |                               ((void *)0)
  | 0-1 | ||||||||||||
| 29 |                                   )
  | 0-1 | ||||||||||||
| 30 | ERR_put_error(13,(0xfff),(109),__FILE__,89); | - | ||||||||||||
| 31 |   return never executed:   (-1);return (-1);never executed:  return (-1); | 0 | ||||||||||||
| 32 | } | - | ||||||||||||
| 33 | p = ASN1_STRING_data(a->value.octet_string); | - | ||||||||||||
| 34 | ret = ASN1_STRING_length(a->value.octet_string); | - | ||||||||||||
| 35 |  if (ret < max_len
  | 0-1 | ||||||||||||
| 36 |   num = ret; never executed:  num = ret; | 0 | ||||||||||||
| 37 | else | - | ||||||||||||
| 38 |   num = max_len; executed 1 time by 1 test:  num = max_len;Executed by: 
  | 1 | ||||||||||||
| 39 | memcpy(data, p, num); | - | ||||||||||||
| 40 |  return executed 1 time by 1 test:   (ret);return (ret);Executed by: 
 executed 1 time by 1 test:  return (ret);Executed by: 
  | 1 | ||||||||||||
| 41 | } | - | ||||||||||||
| 42 | - | |||||||||||||
| 43 | typedef struct { | - | ||||||||||||
| 44 | ASN1_INTEGER *num; | - | ||||||||||||
| 45 | ASN1_OCTET_STRING *value; | - | ||||||||||||
| 46 | } ASN1_int_octetstring; | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | static const ASN1_TEMPLATE ASN1_INT_OCTETSTRING_seq_tt[] = { | - | ||||||||||||
| 49 | { | - | ||||||||||||
| 50 | .offset = | - | ||||||||||||
| 51 | __builtin_offsetof ( | - | ||||||||||||
| 52 | ASN1_int_octetstring | - | ||||||||||||
| 53 | , | - | ||||||||||||
| 54 | num | - | ||||||||||||
| 55 | ) | - | ||||||||||||
| 56 | , | - | ||||||||||||
| 57 | .field_name = "num", | - | ||||||||||||
| 58 | .item = &ASN1_INTEGER_it, | - | ||||||||||||
| 59 | }, | - | ||||||||||||
| 60 | { | - | ||||||||||||
| 61 | .offset = | - | ||||||||||||
| 62 | __builtin_offsetof ( | - | ||||||||||||
| 63 | ASN1_int_octetstring | - | ||||||||||||
| 64 | , | - | ||||||||||||
| 65 | value | - | ||||||||||||
| 66 | ) | - | ||||||||||||
| 67 | , | - | ||||||||||||
| 68 | .field_name = "value", | - | ||||||||||||
| 69 | .item = &ASN1_OCTET_STRING_it, | - | ||||||||||||
| 70 | }, | - | ||||||||||||
| 71 | }; | - | ||||||||||||
| 72 | - | |||||||||||||
| 73 | const ASN1_ITEM ASN1_INT_OCTETSTRING_it = { | - | ||||||||||||
| 74 | .itype = 0x1, | - | ||||||||||||
| 75 | .utype = 16, | - | ||||||||||||
| 76 | .templates = ASN1_INT_OCTETSTRING_seq_tt, | - | ||||||||||||
| 77 | .tcount = sizeof(ASN1_INT_OCTETSTRING_seq_tt) / sizeof(ASN1_TEMPLATE), | - | ||||||||||||
| 78 | .size = sizeof(ASN1_int_octetstring), | - | ||||||||||||
| 79 | .sname = "ASN1_INT_OCTETSTRING", | - | ||||||||||||
| 80 | }; | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | int | - | ||||||||||||
| 83 | ASN1_TYPE_set_int_octetstring(ASN1_TYPE *at, long num, unsigned char *data, | - | ||||||||||||
| 84 | int len) | - | ||||||||||||
| 85 | { | - | ||||||||||||
| 86 | ASN1_int_octetstring *ios; | - | ||||||||||||
| 87 | ASN1_STRING *sp = | - | ||||||||||||
| 88 | ((void *)0) | - | ||||||||||||
| 89 | ; | - | ||||||||||||
| 90 | int ret = 0; | - | ||||||||||||
| 91 | - | |||||||||||||
| 92 |  if ((
 
  | 0-1 | ||||||||||||
| 93 |      &ASN1_INT_OCTETSTRING_it)) == 
  | 0-1 | ||||||||||||
| 94 |                                   ((void *)0)
  | 0-1 | ||||||||||||
| 95 | ) | - | ||||||||||||
| 96 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 97 |  if ((
 
  | 0-1 | ||||||||||||
| 98 |                                        ((void *)0)
  | 0-1 | ||||||||||||
| 99 | ) | - | ||||||||||||
| 100 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 101 |  if (!ASN1_INTEGER_set(ios->num, num)
  | 0-1 | ||||||||||||
| 102 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 103 |  if ((
 
  | 0-1 | ||||||||||||
| 104 |                                               ((void *)0)
  | 0-1 | ||||||||||||
| 105 | ) | - | ||||||||||||
| 106 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 107 |  if (!ASN1_OCTET_STRING_set(ios->value, data, len)
  | 0-1 | ||||||||||||
| 108 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 109 | - | |||||||||||||
| 110 |  if ((
 
  | 0-1 | ||||||||||||
| 111 |                                                         ((void *)0)
  | 0-1 | ||||||||||||
| 112 |                                                             )) == 
  | 0-1 | ||||||||||||
| 113 |                                                                   ((void *)0)
  | 0-1 | ||||||||||||
| 114 | ) | - | ||||||||||||
| 115 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 116 | - | |||||||||||||
| 117 | ASN1_TYPE_set(at, 16, sp); | - | ||||||||||||
| 118 | sp = | - | ||||||||||||
| 119 | ((void *)0) | - | ||||||||||||
| 120 | ; | - | ||||||||||||
| 121 | - | |||||||||||||
| 122 | ret = 1; | - | ||||||||||||
| 123 | - | |||||||||||||
| 124 |  err: code before this statement executed 1 time by 1 test:  err:Executed by: 
  | 1 | ||||||||||||
| 125 | ASN1_item_free((ASN1_VALUE *)ios, &ASN1_INT_OCTETSTRING_it); | - | ||||||||||||
| 126 | ASN1_STRING_free(sp); | - | ||||||||||||
| 127 | - | |||||||||||||
| 128 |  return executed 1 time by 1 test:   ret;return ret;Executed by: 
 executed 1 time by 1 test:  return ret;Executed by: 
  | 1 | ||||||||||||
| 129 | } | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | int | - | ||||||||||||
| 132 | ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *at, long *num, unsigned char *data, | - | ||||||||||||
| 133 | int max_len) | - | ||||||||||||
| 134 | { | - | ||||||||||||
| 135 | ASN1_STRING *sp = at->value.sequence; | - | ||||||||||||
| 136 | ASN1_int_octetstring *ios = | - | ||||||||||||
| 137 | ((void *)0) | - | ||||||||||||
| 138 | ; | - | ||||||||||||
| 139 | int ret = -1; | - | ||||||||||||
| 140 | int len; | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 |  if (at->type != 16
 
  | 0-2 | ||||||||||||
| 143 |                                          ((void *)0)
  | 0-2 | ||||||||||||
| 144 | ) | - | ||||||||||||
| 145 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 146 | - | |||||||||||||
| 147 |  if ((
 
  | 0-2 | ||||||||||||
| 148 |                                                               ((void *)0)
  | 0-2 | ||||||||||||
| 149 | ) | - | ||||||||||||
| 150 |   goto never executed:   err;goto err;never executed:  goto err; | 0 | ||||||||||||
| 151 | - | |||||||||||||
| 152 |  if (num != 
  | 0-2 | ||||||||||||
| 153 |            ((void *)0)
  | 0-2 | ||||||||||||
| 154 | ) | - | ||||||||||||
| 155 |   * executed 2 times by 1 test:  num = ASN1_INTEGER_get(ios->num);*num = ASN1_INTEGER_get(ios->num);Executed by: 
 executed 2 times by 1 test:  *num = ASN1_INTEGER_get(ios->num);Executed by: 
  | 2 | ||||||||||||
| 156 |  if (data != 
  | 0-2 | ||||||||||||
| 157 |             ((void *)0)
  | 0-2 | ||||||||||||
| 158 | ) { | - | ||||||||||||
| 159 | len = ASN1_STRING_length(ios->value); | - | ||||||||||||
| 160 |   if (len > max_len
  | 1 | ||||||||||||
| 161 |    len = max_len; executed 1 time by 1 test:  len = max_len;Executed by: 
  | 1 | ||||||||||||
| 162 | memcpy(data, ASN1_STRING_data(ios->value), len); | - | ||||||||||||
| 163 |  } executed 2 times by 1 test:  end of blockExecuted by: 
  | 2 | ||||||||||||
| 164 | - | |||||||||||||
| 165 | ret = ASN1_STRING_length(ios->value); | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 |  err: code before this statement executed 2 times by 1 test:  err:Executed by: 
  | 2 | ||||||||||||
| 168 | ASN1_item_free((ASN1_VALUE *)ios, &ASN1_INT_OCTETSTRING_it); | - | ||||||||||||
| 169 | - | |||||||||||||
| 170 |  if (ret == -1
  | 0-2 | ||||||||||||
| 171 |   ERR_put_error(13,(0xfff),(109),__FILE__,194); never executed:  ERR_put_error(13,(0xfff),(109),__FILE__,194); | 0 | ||||||||||||
| 172 | - | |||||||||||||
| 173 |  return executed 2 times by 1 test:   ret;return ret;Executed by: 
 executed 2 times by 1 test:  return ret;Executed by: 
  | 2 | ||||||||||||
| 174 | } | - | ||||||||||||
| Switch to Source code | Preprocessed file |