forked from wolfSSL/wolfssl
Address buffer underflow, thanks to J.S. for the report on ZD10580
This commit is contained in:
@ -10555,9 +10555,22 @@ int PemToDer(const unsigned char* buff, long longSz, int type,
|
|||||||
#ifndef NO_WOLFSSL_SKIP_TRAILING_PAD
|
#ifndef NO_WOLFSSL_SKIP_TRAILING_PAD
|
||||||
#ifndef NO_DES3
|
#ifndef NO_DES3
|
||||||
if (info->cipherType == WC_CIPHER_DES3) {
|
if (info->cipherType == WC_CIPHER_DES3) {
|
||||||
padVal = der->buffer[der->length-1];
|
/* Assuming there is padding:
|
||||||
if (padVal <= DES_BLOCK_SIZE) {
|
* (der->length > 0 &&
|
||||||
der->length -= padVal;
|
* (der->length % DES_BLOCK_SIZE) != 0)
|
||||||
|
* and assuming the last value signifies the number of
|
||||||
|
* padded bytes IE if last value is 0x08 then there are
|
||||||
|
* 8 bytes of padding:
|
||||||
|
* padVal = der->buffer[der->length-1];
|
||||||
|
* then strip this padding before proceeding:
|
||||||
|
* der->length -= padVal;
|
||||||
|
*/
|
||||||
|
if (der->length > 0 &&
|
||||||
|
(der->length % DES_BLOCK_SIZE) != 0) {
|
||||||
|
padVal = der->buffer[der->length-1];
|
||||||
|
if (padVal <= DES_BLOCK_SIZE) {
|
||||||
|
der->length -= padVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !NO_DES3 */
|
#endif /* !NO_DES3 */
|
||||||
|
Reference in New Issue
Block a user