Skip to content

Commit 3bc14cf

Browse files
committed
src/ngx_http_lua_ssl_session_fetchby.c: fix possible null pointer dereference found by Coverity
443 c = log->data; 444 deref_ptr: Directly dereferencing pointer c. 445 if (c->addr_text.len) { 446 p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text); 447 len -= p - buf; 448 buf = p; 449 } 450 CID 251611 (openresty#1 of 1): Dereference before null check (REVERSE_INULL)check_after_deref: Null-checking c suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 451 if (c && c->listening && c->listening->addr_text.len) { 452 p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text); 453 buf = p; 454 }
1 parent 23e40f3 commit 3bc14cf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/ngx_http_lua_ssl_session_fetchby.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,17 @@ ngx_http_lua_log_ssl_sess_fetch_error(ngx_log_t *log, u_char *buf, size_t len)
442442

443443
c = log->data;
444444

445-
if (c->addr_text.len) {
446-
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
447-
len -= p - buf;
448-
buf = p;
449-
}
445+
if (c) {
446+
if (c->addr_text.len) {
447+
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
448+
len -= p - buf;
449+
buf = p;
450+
}
450451

451-
if (c && c->listening && c->listening->addr_text.len) {
452-
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
453-
buf = p;
452+
if (c->listening && c->listening->addr_text.len) {
453+
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
454+
buf = p;
455+
}
454456
}
455457

456458
return buf;

0 commit comments

Comments
 (0)