Skip to content

Commit 3137d62

Browse files
committed
fix issue where ToTraditional_ex may assign negative value to *pkeySz
1 parent 00e1fa6 commit 3137d62

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

wolfcrypt/src/pkcs12.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,8 +1562,13 @@ int wc_PKCS12_parse_ex(WC_PKCS12* pkcs12, const char* psw,
15621562
*pkeySz = (word32)size;
15631563
}
15641564
else {
1565-
*pkeySz = (word32)ToTraditional_ex(*pkey,
1566-
(word32)size, &algId);
1565+
ret = ToTraditional_ex(*pkey,
1566+
(word32)size, &algId);
1567+
if (ret < 0) {
1568+
*pkeySz = (word32)size;
1569+
goto exit_pk12par;
1570+
}
1571+
*pkeySz = (word32)ret;
15671572
}
15681573
}
15691574

0 commit comments

Comments
 (0)