Check for errors in a2d_ASN1_OBJECT() Check for error return in BN_div_word(). (Imported from upstream's d871284aca5524c85a6460119ac1b1e38f7e19c6.) This function is only called from crypto/obj to convert strings like "1.2.3.4.5" to OIDs. We may wish to see about rewriting it just so it's out of the way. Change-Id: Ia8379d2dd30606f6a81ce24dee8852312cb7f127 Reviewed-on: https://boringssl-review.googlesource.com/10365 Commit-Queue: David Benjamin <davidben@google.com> Commit-Queue: Adam Langley <agl@google.com> Reviewed-by: Adam Langley <agl@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
diff --git a/crypto/asn1/a_object.c b/crypto/asn1/a_object.c index 561eb14..fef9b79 100644 --- a/crypto/asn1/a_object.c +++ b/crypto/asn1/a_object.c
@@ -172,8 +172,12 @@ if (!tmp) goto err; } - while (blsize--) - tmp[i++] = (unsigned char)BN_div_word(bl, 0x80L); + while (blsize--) { + BN_ULONG t = BN_div_word(bl, 0x80L); + if (t == (BN_ULONG)-1) + goto err; + tmp[i++] = (unsigned char)t; + } } else { for (;;) {