Skip to content

Commit d6c8e7b

Browse files
committed
add tmp variable to satisfy coverity before casting and assigning to word32 variable
1 parent 5c257e1 commit d6c8e7b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

wolfcrypt/src/asn.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42214,17 +42214,19 @@ static int EncodeCrlSerial(const byte* sn, word32 snSz, byte* output,
4221442214
*/
4221542215
static word32 EncodeRevokedCert(byte* output, const RevokedCert* rc)
4221642216
{
42217+
int tmpSnSz;
4221742218
word32 idx = 0;
4221842219
word32 snSz, dateSz, seqSz;
4221942220
byte snBuf[MAX_SN_SZ];
4222042221
byte dateBuf[MAX_DATE_SIZE + 2]; /* tag + length + data */
4222142222
byte seqBuf[MAX_SEQ_SZ];
4222242223

4222342224
/* Encode serial number */
42224-
snSz = (word32)EncodeCrlSerial(rc->serialNumber, (word32)rc->serialSz,
42225+
tmpSnSz = EncodeCrlSerial(rc->serialNumber, (word32)rc->serialSz,
4222542226
snBuf, sizeof(snBuf));
42226-
if ((int)snSz < 0)
42227+
if (tmpSnSz < 0)
4222742228
return 0;
42229+
snSz = (word32)tmpSnSz;
4222842230

4222942231
/* Encode revocation date */
4223042232
dateSz = EncodeCrlDate(dateBuf, rc->revDate, rc->revDateFormat);
@@ -42255,6 +42257,7 @@ static word32 EncodeRevokedCert(byte* output, const RevokedCert* rc)
4225542257
static word32 EncodeCrlNumberExt(byte* output, const byte* crlNum,
4225642258
word32 crlNumSz)
4225742259
{
42260+
int tmpIntSz;
4225842261
word32 idx = 0;
4225942262
word32 oidSz, intSz, octetSz, seqSz;
4226042263
byte seqBuf[MAX_SEQ_SZ];
@@ -42266,9 +42269,10 @@ static word32 EncodeCrlNumberExt(byte* output, const byte* crlNum,
4226642269
oidSz = sizeof(crlNumOid);
4226742270

4226842271
/* Encode the INTEGER for CRL number */
42269-
intSz = (word32)EncodeCrlSerial(crlNum, crlNumSz, intBuf, sizeof(intBuf));
42270-
if ((int)intSz < 0)
42272+
tmpIntSz = EncodeCrlSerial(crlNum, crlNumSz, intBuf, sizeof(intBuf));
42273+
if (tmpIntSz < 0)
4227142274
return 0;
42275+
intSz = (word32)tmpIntSz;
4227242276

4227342277
/* Wrap INTEGER in OCTET STRING */
4227442278
octetSz = SetOctetString(intSz, octetBuf);

0 commit comments

Comments
 (0)