Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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