i2d_SSL_SESSION() may unexpectedly return a negative value on
memory allocation failure, even though the NULL buffer was passed,
notably in LibreSSL.
Reported by szzzy.
/* do not cache too big session */
- if (len > NGX_SSL_MAX_SESSION_SIZE) {
+ if (len <= 0 || len > NGX_SSL_MAX_SESSION_SIZE) {
return 0;
}
/* do not cache too big session */
- if (len > NGX_SSL_MAX_SESSION_SIZE) {
+ if (len <= 0 || len > NGX_SSL_MAX_SESSION_SIZE) {
return;
}
/* do not cache too big session */
- if (len > NGX_SSL_MAX_SESSION_SIZE) {
+ if (len <= 0 || len > NGX_SSL_MAX_SESSION_SIZE) {
return;
}