Skip to content

fix: add NULL-checks for shared buffer allocation in ngx_rtmp_live_av#1793

Open
Fahnenfluchtige wants to merge 4 commits intoarut:masterfrom
Fahnenfluchtige:aapkt_check
Open

fix: add NULL-checks for shared buffer allocation in ngx_rtmp_live_av#1793
Fahnenfluchtige wants to merge 4 commits intoarut:masterfrom
Fahnenfluchtige:aapkt_check

Conversation

@Fahnenfluchtige
Copy link

The Svace static analysis tool identified a potential issue in the function ngx_rtmp_live_av, where the return value of ngx_rtmp_append_shared_bufs and ngx_rtmp_alloc_shared_bufs is not checked properly. After allocation or appending the value is sending to the function ngx_rtmp_prepare_message (or ngx_rtmp_send_message) which can cause the null-dereference.

So the solution is to add null-checking, like there:

--- a/ngx_rtmp_live_module.c
+++ b/ngx_rtmp_live_module.c
@@ -803,6 +803,11 @@ ngx_rtmp_live_av(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
     }
 */
     rpkt = ngx_rtmp_append_shared_bufs(cscf, NULL, in);
+    if (rpkt == NULL) {
+        ngx_log_error(NGX_LOG_ERR, s->connection->log, 0,
+                      "live: failed to append packet buffers");
+        return NGX_OK;
+    }
 
     ngx_rtmp_prepare_message(s, &ch, &lh, rpkt);
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant