hx509: Return better error in CSR authorization functions

This commit is contained in:
Nicolas Williams
2022-11-29 17:57:14 -06:00
parent ce1dd5fc76
commit 4da64d119e

View File

@@ -977,7 +977,7 @@ abitstring_check(abitstring a, size_t n, int idx)
size_t bytes;
if (idx >= n)
return EINVAL;
return HX509_NO_ITEM;
bytes = (idx + 1) / CHAR_BIT + (((idx + 1) % CHAR_BIT) ? 1 : 0);
if (a->feat_bytes < bytes)
@@ -996,7 +996,7 @@ abitstring_set(abitstring a, size_t n, int idx)
size_t bytes;
if (idx >= n)
return EINVAL;
return HX509_NO_ITEM;
bytes = n / CHAR_BIT + ((n % CHAR_BIT) ? 1 : 0);
if (a->feat_bytes < bytes) {
@@ -1026,7 +1026,7 @@ abitstring_reset(abitstring a, size_t n, int idx)
size_t bytes;
if (idx >= n)
return EINVAL;
return HX509_NO_ITEM;
bytes = (idx + 1) / CHAR_BIT + (((idx + 1) % CHAR_BIT) ? 1 : 0);
if (a->feat_bytes >= bytes &&