Skip to content

Commit 454cd04

Browse files
committed
[fix] fix some heap-use-after-free bugs (found by gcc asan).
1 parent 8baf9a8 commit 454cd04

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ngx_http_flv_live_module.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,7 @@ ngx_http_flv_live_close_stream(ngx_rtmp_session_t *s,
13081308
static void
13091309
ngx_http_flv_live_free_request(ngx_rtmp_session_t *s)
13101310
{
1311+
ngx_connection_t *c;
13111312
ngx_http_request_t *r;
13121313
ngx_http_cleanup_t **cln;
13131314

@@ -1322,20 +1323,22 @@ ngx_http_flv_live_free_request(ngx_rtmp_session_t *s)
13221323
cln = &(*cln)->next;
13231324
}
13241325

1326+
c = r->connection;
1327+
13251328
#if (nginx_version <= 1003014)
13261329
ngx_http_do_free_request(r, 0);
13271330
#else
13281331
ngx_http_free_request(r, 0);
13291332
#endif
13301333

13311334
#if (NGX_HTTP_SSL)
1332-
if (r->connection->ssl) {
1333-
ngx_ssl_shutdown(r->connection);
1335+
if (c->ssl) {
1336+
ngx_ssl_shutdown(c);
13341337
}
13351338
#endif
13361339

13371340
/* for later processing */
1338-
r->connection->destroyed = 0;
1341+
c->destroyed = 0;
13391342
}
13401343
}
13411344

@@ -2017,10 +2020,12 @@ ngx_http_flv_live_connect_init(ngx_rtmp_session_t *s, ngx_str_t *app,
20172020
ngx_str_t *stream)
20182021
{
20192022
ngx_rtmp_connect_t v;
2023+
ngx_connection_t *c;
20202024
ngx_http_request_t *r;
20212025
u_char name[NGX_RTMP_MAX_NAME];
20222026

20232027
r = s->data;
2028+
c = s->connection;
20242029

20252030
ngx_memzero(&v, sizeof(ngx_rtmp_connect_t));
20262031

@@ -2033,7 +2038,7 @@ ngx_http_flv_live_connect_init(ngx_rtmp_session_t *s, ngx_str_t *app,
20332038

20342039
#define NGX_RTMP_SET_STRPAR(name) \
20352040
s->name.len = ngx_strlen(v.name); \
2036-
s->name.data = ngx_palloc(r->pool, s->name.len); \
2041+
s->name.data = ngx_palloc(c->pool, s->name.len); \
20372042
ngx_memcpy(s->name.data, v.name, s->name.len)
20382043

20392044
NGX_RTMP_SET_STRPAR(app);
@@ -2060,7 +2065,7 @@ ngx_http_flv_live_connect_init(ngx_rtmp_session_t *s, ngx_str_t *app,
20602065
}
20612066

20622067
s->stream.len = stream->len;
2063-
s->stream.data = ngx_pstrdup(r->pool, stream);
2068+
s->stream.data = ngx_pstrdup(c->pool, stream);
20642069

20652070
return ngx_rtmp_connect(s, &v);
20662071
}

0 commit comments

Comments
 (0)