src/{pk.c,x509.c}: style/clarity cleanups from dgarske.

This commit is contained in:
Daniel Pouzzner
2022-06-30 16:31:25 -05:00
parent 1a9388b935
commit 4f6527353b
2 changed files with 13 additions and 6 deletions

View File

@ -155,7 +155,8 @@ static int wolfssl_print_indent(WOLFSSL_BIO* bio, char* line, int lineLen,
if (len_wanted >= lineLen) {
WOLFSSL_MSG("Buffer overflow formatting indentation");
ret = 0;
} else {
}
else {
/* Write indents string to BIO */
if (wolfSSL_BIO_write(bio, line, len_wanted) <= 0) {
ret = 0;
@ -261,7 +262,8 @@ static int wolfssl_print_number(WOLFSSL_BIO* bio, mp_int* num, const char* name,
if (li >= (int)sizeof(line)) {
WOLFSSL_MSG("Buffer overflow formatting name");
ret = 0;
} else {
}
else {
if (wolfSSL_BIO_write(bio, line, li) <= 0) {
ret = 0;
}
@ -306,8 +308,10 @@ static int wolfssl_print_number(WOLFSSL_BIO* bio, mp_int* num, const char* name,
/* Put the leading spaces on new line. */
XSTRNCPY(line, PRINT_NUM_INDENT, PRINT_NUM_INDENT_CNT + 1);
li = PRINT_NUM_INDENT_CNT;
} else
}
else {
li += len_wanted;
}
}
if (ret == 1) {
@ -1922,7 +1926,8 @@ int wolfSSL_RSA_print(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa, int indent)
if (len >= (int)sizeof(line)) {
WOLFSSL_MSG("Buffer overflow while formatting key preamble");
ret = 0;
} else {
}
else {
if (wolfSSL_BIO_write(bio, line, len) <= 0) {
ret = 0;
}

View File

@ -6244,10 +6244,12 @@ int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp,
return WOLFSSL_FAILURE;
}
if ((sigalg->algorithm->obj == NULL) || (sigalg->algorithm->obj[idx++] != ASN_OBJECT_ID)) {
if ((sigalg->algorithm->obj == NULL) ||
(sigalg->algorithm->obj[idx] != ASN_OBJECT_ID)) {
WOLFSSL_MSG("Bad ASN1 Object");
return WOLFSSL_FAILURE;
}
idx++; /* skip object id */
if (GetLength((const byte*)sigalg->algorithm->obj, &idx, &length,
sigalg->algorithm->objSz) < 0 || length < 0) {
@ -6262,7 +6264,7 @@ int wolfSSL_X509_signature_print(WOLFSSL_BIO *bp,
for (i = 0; i < length; ++i) {
char hex_digits[4];
#ifdef XSNPRINTF
XSNPRINTF(hex_digits, sizeof hex_digits, "%c%02X", i>0 ? ':' : ' ',
XSNPRINTF(hex_digits, sizeof(hex_digits), "%c%02X", i>0 ? ':' : ' ',
(unsigned int)sigalg->algorithm->obj[idx+i]);
#else
XSPRINTF(hex_digits, "%c%02X", i>0 ? ':' : ' ',