mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 03:34:39 +02:00
Fix scan-build report of possible use of unitialized output[i].
This commit is contained in:
@@ -6391,7 +6391,7 @@ WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* output)
|
||||
int i = 0;
|
||||
int snSzInt = (int)snSz;
|
||||
|
||||
if (sn == NULL || output == NULL)
|
||||
if (sn == NULL || output == NULL || snSzInt < 0)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
/* remove leading zeros */
|
||||
@@ -6405,8 +6405,10 @@ WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* output)
|
||||
i += SetLength(snSzInt, &output[i]);
|
||||
XMEMCPY(&output[i], sn, snSzInt);
|
||||
|
||||
/* ensure positive (MSB not set) */
|
||||
output[i] &= ~0x80;
|
||||
if (snSzInt > 0) {
|
||||
/* ensure positive (MSB not set) */
|
||||
output[i] &= ~0x80;
|
||||
}
|
||||
|
||||
/* compute final length */
|
||||
i += snSzInt;
|
||||
|
Reference in New Issue
Block a user