Skip to content

Commit 1d30518

Browse files
committed
fixed crash on hls audio buffer overflow
1 parent ed98ca4 commit 1d30518

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

hls/ngx_rtmp_hls_module.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,16 +1282,22 @@ ngx_rtmp_hls_audio(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
12821282
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
12831283
"hls: audio pts=%uL", pts);
12841284

1285+
if (b->last + 7 > b->end) {
1286+
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
1287+
"hls: not enough buffer for audio header");
1288+
return NGX_OK;
1289+
}
1290+
12851291
p = b->last;
12861292
b->last += 5;
12871293

12881294
/* copy payload */
12891295

1290-
for (; in; in = in->next) {
1296+
for (; in && b->last < b->end; in = in->next) {
12911297

12921298
bsize = in->buf->last - in->buf->pos;
12931299
if (b->last + bsize > b->end) {
1294-
break;
1300+
bsize = b->end - b->last;
12951301
}
12961302

12971303
b->last = ngx_cpymem(b->last, in->buf->pos, bsize);

0 commit comments

Comments
 (0)