Преглед на файлове

bytestring: document that |CBS_get_optional_asn1| can have a NULL output.

On the other hand, the type-specific
|CBS_get_optional_asn1_octet_string| must have a valid pointer and we
should check this in the “present” case or there could be a lucking
crash in some user waiting for an expected value to be missing.

Change-Id: Ida40e069ac7f0e50967e3f6c6b3fc01e49bd8894
Reviewed-on: https://boringssl-review.googlesource.com/26564
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
kris/onging/CECPQ3_patch15
Adam Langley преди 6 години
committed by CQ bot account: commit-bot@chromium.org
родител
ревизия
d096c06b34
променени са 2 файла, в които са добавени 5 реда и са изтрити 4 реда
  1. +1
    -0
      crypto/bytestring/cbs.c
  2. +4
    -4
      include/openssl/bytestring.h

+ 1
- 0
crypto/bytestring/cbs.c Целия файл

@@ -466,6 +466,7 @@ int CBS_get_optional_asn1_octet_string(CBS *cbs, CBS *out, int *out_present,
return 0;
}
if (present) {
assert(out);
if (!CBS_get_asn1(&child, out, CBS_ASN1_OCTETSTRING) ||
CBS_len(&child) != 0) {
return 0;


+ 4
- 4
include/openssl/bytestring.h Целия файл

@@ -240,10 +240,10 @@ OPENSSL_EXPORT int CBS_get_asn1_uint64(CBS *cbs, uint64_t *out);
OPENSSL_EXPORT int CBS_get_asn1_bool(CBS *cbs, int *out);

// CBS_get_optional_asn1 gets an optional explicitly-tagged element from |cbs|
// tagged with |tag| and sets |*out| to its contents. If present and if
// |out_present| is not NULL, it sets |*out_present| to one, otherwise zero. It
// returns one on success, whether or not the element was present, and zero on
// decode failure.
// tagged with |tag| and sets |*out| to its contents, or ignores it if |out| is
// NULL. If present and if |out_present| is not NULL, it sets |*out_present| to
// one, otherwise zero. It returns one on success, whether or not the element
// was present, and zero on decode failure.
OPENSSL_EXPORT int CBS_get_optional_asn1(CBS *cbs, CBS *out, int *out_present,
unsigned tag);



Зареждане…
Отказ
Запис