check error_string_n size and truncate if too short
This commit is contained in:
parent
8f5e98486f
commit
10e6e7fbb5
13
src/ssl.c
13
src/ssl.c
@ -632,7 +632,18 @@ char* CyaSSL_ERR_error_string(unsigned long errNumber, char* data)
|
||||
void CyaSSL_ERR_error_string_n(unsigned long e, char* buf, unsigned long len)
|
||||
{
|
||||
CYASSL_ENTER("CyaSSL_ERR_error_string_n");
|
||||
if (len) CyaSSL_ERR_error_string(e, buf);
|
||||
if (len >= MAX_ERROR_SZ)
|
||||
CyaSSL_ERR_error_string(e, buf);
|
||||
else {
|
||||
char tmp[MAX_ERROR_SZ];
|
||||
|
||||
CYASSL_MSG("Error buffer too short, truncating");
|
||||
if (len) {
|
||||
CyaSSL_ERR_error_string(e, tmp);
|
||||
XMEMCPY(buf, tmp, len-1);
|
||||
buf[len-1] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user