]> git.kaiwu.me - nginx.git/commitdiff
Mp4: fixed handling an empty run of chunks in stsc atom.
authorRoman Arutyunyan <arut@nginx.com>
Mon, 23 Sep 2024 11:51:30 +0000 (15:51 +0400)
committerpluknet <pluknet@nginx.com>
Wed, 5 Feb 2025 16:40:47 +0000 (20:40 +0400)
A specially crafted mp4 file with an empty run of chunks in the stsc atom
and a large value for samples per chunk for that run, combined with a
specially crafted request, allowed to store that large value in prev_samples
and later in trak->end_chunk_samples while in ngx_http_mp4_crop_stsc_data().
Later in ngx_http_mp4_update_stsz_atom() this could result in buffer
overread while calculating trak->end_chunk_samples_size.

Now the value of samples per chunk specified for an empty run is ignored.

src/http/modules/ngx_http_mp4_module.c

index 041ad263b56149d9d5878b72ddad549dddbf4f49..2ca0591367d257003226374a132f8d5d3e28240f 100644 (file)
@@ -3176,7 +3176,10 @@ ngx_http_mp4_crop_stsc_data(ngx_http_mp4_file_t *mp4,
 
         start_sample -= n;
 
-        prev_samples = samples;
+        if (next_chunk > chunk) {
+            prev_samples = samples;
+        }
+
         chunk = next_chunk;
         samples = ngx_mp4_get_32value(entry->samples);
         id = ngx_mp4_get_32value(entry->id);