aboutsummaryrefslogtreecommitdiff
path: root/crypto/asn1/a_bitstr.c
diff options
context:
space:
mode:
authorPierre Pronchery <pierre@freebsdfoundation.org>2023-05-31 22:06:50 +0000
committerEd Maste <emaste@FreeBSD.org>2023-06-23 13:13:27 +0000
commitb84c4564effd02dfdc047dd6cbeaf910bbb1a888 (patch)
tree39604e7e6f13fced003ef2f77c35f3989aa574ca /crypto/asn1/a_bitstr.c
parente4520c8bd1d300a7a338d0ed4af171a2d0e583ef (diff)
Diffstat (limited to 'crypto/asn1/a_bitstr.c')
-rw-r--r--crypto/asn1/a_bitstr.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/asn1/a_bitstr.c b/crypto/asn1/a_bitstr.c
index 7c256493571e..4930d5022ee3 100644
--- a/crypto/asn1/a_bitstr.c
+++ b/crypto/asn1/a_bitstr.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -148,6 +148,9 @@ int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value)
int w, v, iv;
unsigned char *c;
+ if (n < 0)
+ return 0;
+
w = n / 8;
v = 1 << (7 - (n & 0x07));
iv = ~v;
@@ -182,6 +185,9 @@ int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n)
{
int w, v;
+ if (n < 0)
+ return 0;
+
w = n / 8;
v = 1 << (7 - (n & 0x07));
if ((a == NULL) || (a->length < (w + 1)) || (a->data == NULL))