Skip to content

Commit e67b857

Browse files
committed
Fix from testing
1 parent bae25af commit e67b857

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

src/x509.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#endif
2828
#else
2929

30-
#pragma GCC diagnostic ignored "-Wformat-truncation"
31-
3230
#ifndef WOLFCRYPT_ONLY
3331

3432
#ifndef NO_CERTS
@@ -1476,6 +1474,12 @@ static WOLFSSL_ASN1_STRING* wolfSSL_X509_EXTENSION_get_data_internal(
14761474

14771475

14781476
#ifndef NO_BIO
1477+
1478+
#ifndef MAX_INDENT
1479+
#define MAX_INDENT 40
1480+
#endif
1481+
1482+
14791483
/* Return 0 on success and 1 on failure. Copies ext data to bio, using indent
14801484
* to pad the output. flag is ignored. */
14811485
int wolfSSL_X509V3_EXT_print(WOLFSSL_BIO *out, WOLFSSL_X509_EXTENSION *ext,
@@ -1490,6 +1494,9 @@ int wolfSSL_X509V3_EXT_print(WOLFSSL_BIO *out, WOLFSSL_X509_EXTENSION *ext,
14901494
int tmpLen = 0;
14911495
WOLFSSL_ENTER("wolfSSL_X509V3_EXT_print");
14921496

1497+
if (indent < 0) indent = 0;
1498+
if (indent > MAX_INDENT) indent = MAX_INDENT;
1499+
14931500
if ((out == NULL) || (ext == NULL)) {
14941501
WOLFSSL_MSG("NULL parameter error");
14951502
return rc;
@@ -6322,6 +6329,9 @@ static int X509PrintKeyUsage(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, int indent)
63226329
"Decipher Only"
63236330
};
63246331

6332+
if (indent < 0) indent = 0;
6333+
if (indent > MAX_INDENT) indent = MAX_INDENT;
6334+
63256335
if (bio == NULL || x509 == NULL) {
63266336
ret = WOLFSSL_FAILURE;
63276337
}
@@ -6493,6 +6503,9 @@ static int X509PrintSerial(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, int indent)
64936503
unsigned char serial[32];
64946504
int sz = sizeof(serial);
64956505

6506+
if (indent < 0) indent = 0;
6507+
if (indent > MAX_INDENT) indent = MAX_INDENT;
6508+
64966509
XMEMSET(serial, 0, sz);
64976510
if (wolfSSL_X509_get_serial_number(x509, serial, &sz) == WOLFSSL_SUCCESS) {
64986511
X509PrintSerial_ex(bio, serial, sz, 1, indent);
@@ -6585,6 +6598,9 @@ static int X509PrintExtensions(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, int indent)
65856598
int count, i;
65866599
char* buf = NULL;
65876600

6601+
if (indent < 0) indent = 0;
6602+
if (indent > MAX_INDENT) indent = MAX_INDENT;
6603+
65886604
count = wolfSSL_X509_get_ext_count(x509);
65896605
if (count <= 0)
65906606
return WOLFSSL_SUCCESS;
@@ -6998,6 +7014,9 @@ static int X509PrintPubKey(WOLFSSL_BIO* bio, WOLFSSL_X509* x509, int indent)
69987014
int len;
69997015
int ret = WOLFSSL_SUCCESS;
70007016

7017+
if (indent < 0) indent = 0;
7018+
if (indent > MAX_INDENT) indent = MAX_INDENT;
7019+
70017020
if (bio == NULL || x509 == NULL)
70027021
return BAD_FUNC_ARG;
70037022

@@ -7085,6 +7104,9 @@ static int X509PrintVersion(WOLFSSL_BIO* bio, int version, int indent)
70857104
char scratch[MAX_WIDTH];
70867105
int scratchLen;
70877106

7107+
if (indent < 0) indent = 0;
7108+
if (indent > MAX_INDENT) indent = MAX_INDENT;
7109+
70887110
scratchLen = XSNPRINTF(scratch, MAX_WIDTH, "%*s%s", indent, "", "Version:");
70897111
if ((scratchLen < 0) || (scratchLen >= MAX_WIDTH)) {
70907112
return WOLFSSL_FAILURE;
@@ -7118,6 +7140,9 @@ static int X509PrintReqAttributes(WOLFSSL_BIO* bio, WOLFSSL_X509* x509,
71187140
int scratchLen;
71197141
int i = 0;
71207142

7143+
if (indent < 0) indent = 0;
7144+
if (indent > MAX_INDENT) indent = MAX_INDENT;
7145+
71217146
if ((scratchLen = XSNPRINTF(scratch, MAX_WIDTH,
71227147
"%*s%s", indent, "", "Attributes: \n"))
71237148
>= MAX_WIDTH)
@@ -8865,6 +8890,9 @@ static int X509RevokedPrintSerial(WOLFSSL_BIO* bio, RevokedCert* rev,
88658890
unsigned char serial[32];
88668891
int sz = sizeof(serial);
88678892

8893+
if (indent < 0) indent = 0;
8894+
if (indent > MAX_INDENT) indent = MAX_INDENT;
8895+
88688896
XMEMSET(serial, 0, sz);
88698897
if (wolfSSL_X509_REVOKED_get_serial_number(rev, serial, &sz)
88708898
== WOLFSSL_SUCCESS) {
@@ -8926,6 +8954,9 @@ static int X509CRLPrintExtensions(WOLFSSL_BIO* bio, WOLFSSL_X509_CRL* crl,
89268954
char tmp[MAX_WIDTH]; /* buffer for XSNPRINTF */
89278955
int ret = 0;
89288956

8957+
if (indent < 0) indent = 0;
8958+
if (indent > MAX_INDENT) indent = MAX_INDENT;
8959+
89298960
if (XSNPRINTF(tmp, MAX_WIDTH, "%*s%s\n", indent, "",
89308961
"CRL extensions:") >= MAX_WIDTH) {
89318962
ret = WOLFSSL_FAILURE;

0 commit comments

Comments
 (0)