mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 12:14:38 +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 i = 0;
|
||||||
int snSzInt = (int)snSz;
|
int snSzInt = (int)snSz;
|
||||||
|
|
||||||
if (sn == NULL || output == NULL)
|
if (sn == NULL || output == NULL || snSzInt < 0)
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
|
|
||||||
/* remove leading zeros */
|
/* remove leading zeros */
|
||||||
@@ -6405,8 +6405,10 @@ WOLFSSL_LOCAL int SetSerialNumber(const byte* sn, word32 snSz, byte* output)
|
|||||||
i += SetLength(snSzInt, &output[i]);
|
i += SetLength(snSzInt, &output[i]);
|
||||||
XMEMCPY(&output[i], sn, snSzInt);
|
XMEMCPY(&output[i], sn, snSzInt);
|
||||||
|
|
||||||
/* ensure positive (MSB not set) */
|
if (snSzInt > 0) {
|
||||||
output[i] &= ~0x80;
|
/* ensure positive (MSB not set) */
|
||||||
|
output[i] &= ~0x80;
|
||||||
|
}
|
||||||
|
|
||||||
/* compute final length */
|
/* compute final length */
|
||||||
i += snSzInt;
|
i += snSzInt;
|
||||||
|
Reference in New Issue
Block a user