commit | 1e63b0ce530a748ef564014c3cb111b1161c89fd | [log] [tgz] |
---|---|---|
author | David Benjamin <davidben@google.com> | Sat Dec 03 17:08:13 2022 -0500 |
committer | Boringssl LUCI CQ <boringssl-scoped@luci-project-accounts.iam.gserviceaccount.com> | Fri Dec 09 02:19:35 2022 +0000 |
tree | ce699ecfbcbd50a644ed643fbc656467312a5d7d | |
parent | b15e56a69486d03996064500e2f06d6a5df5e6a0 [diff] |
Replace comment with static assert. Addressing review comment in https://boringssl-review.googlesource.com/c/boringssl/+/55449/1/crypto/asn1/a_strex.c Bug: 516 Change-Id: I97a74b2d6b041961a573c124c69748e01c0e49d8 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/55505 Reviewed-by: Bob Beck <bbe@google.com> Auto-Submit: David Benjamin <davidben@google.com> Commit-Queue: Bob Beck <bbe@google.com>
diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index 229de94..f21d146 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c
@@ -59,6 +59,7 @@ #include <assert.h> #include <ctype.h> #include <inttypes.h> +#include <limits.h> #include <string.h> #include <time.h> @@ -121,7 +122,8 @@ return maybe_write(out, &u8, 1) ? 1 : -1; } - int len = (int)strlen(buf); // |buf| is guaranteed to be short. + static_assert(sizeof(buf) < INT_MAX, "len may not fit in int"); + int len = (int)strlen(buf); return maybe_write(out, buf, len) ? len : -1; }