Skip to content

Commit 6844ceb

Browse files
committed
src/ngx_http_lua_ssl_session_storeby.c: fix possible null pointer dereference found by Coverity
329 c = log->data; 330 deref_ptr: Directly dereferencing pointer c. 331 if (c->addr_text.len) { 332 p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text); 333 len -= p - buf; 334 buf = p; 335 } 336 CID 251578 (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. 337 if (c && c->listening && c->listening->addr_text.len) { 338 p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text); 339 buf = p; 340 } 341
1 parent 23e40f3 commit 6844ceb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/ngx_http_lua_ssl_session_storeby.c

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

329329
c = log->data;
330330

331-
if (c->addr_text.len) {
332-
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
333-
len -= p - buf;
334-
buf = p;
335-
}
331+
if (c) {
332+
if (c->addr_text.len) {
333+
p = ngx_snprintf(buf, len, ", client: %V", &c->addr_text);
334+
len -= p - buf;
335+
buf = p;
336+
}
336337

337-
if (c && c->listening && c->listening->addr_text.len) {
338-
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
339-
buf = p;
338+
if (c->listening && c->listening->addr_text.len) {
339+
p = ngx_snprintf(buf, len, ", server: %V", &c->listening->addr_text);
340+
buf = p;
341+
}
340342
}
341343

342344
return buf;

0 commit comments

Comments
 (0)