[PATCH] Mp4: fixed setting wrong mdat atom size in very rarecases.
胡聪 (hucc)
hucong.c at foxmail.com
Tue Nov 22 06:13:11 UTC 2016
Hi,
On Tue, Nov 22, 2016 at 4:37 AM +0300, Valentin V. Bartenev wrote:
>On Monday 21 November 2016 23:10:25 胡聪 wrote:
>
>> - if ((uint64_t) atom_data_size > (uint64_t) 0xffffffff) {
>> + if ((uint64_t) atom_data_size + sizeof(ngx_mp4_atom_header_t)
>> + > (uint64_t) 0xffffffff)
>> + {
>> atom_size = 1;
>
>Maxim wrote the expression the way that almost all compilers should optimize
>it to comparison with one static constant. I'm not sure about your case.
Yes, that is a matter. I checked that the above situation does not seem to be
optimized.
# HG changeset patch
# User hucongcong <hucong.c at foxmail.com>
# Date 1479793208 -28800
# Tue Nov 22 13:40:08 2016 +0800
# Node ID 7a4d011601cefeda16c8de2630ae0cc7639edf84
# Parent 2c7a2d75938a31044552b0a6cd6edaebdaf0bd69
Mp4: fixed setting wrong mdat atom size in very rare cases.
Atom size is the sum of atom header size and atom data size. The
specification says that the first 4 bytes are set to one when
the atom size is greater than the maximum unsigned 32-bit value.
Which means atom header size should be considered when the
comparison takes place between atom data size and 0xffffffff.
diff -r 2c7a2d75938a -r 7a4d011601ce src/http/modules/ngx_http_mp4_module.c
--- a/src/http/modules/ngx_http_mp4_module.c Mon Nov 21 16:49:19 2016 +0300
+++ b/src/http/modules/ngx_http_mp4_module.c Tue Nov 22 13:40:08 2016 +0800
@@ -1229,7 +1229,9 @@ ngx_http_mp4_update_mdat_atom(ngx_http_m
atom_header = mp4->mdat_atom_header;
- if ((uint64_t) atom_data_size > (uint64_t) 0xffffffff) {
+ if ((uint64_t) atom_data_size
+ > (uint64_t) 0xffffffff - sizeof(ngx_mp4_atom_header_t))
+ {
atom_size = 1;
atom_header_size = sizeof(ngx_mp4_atom_header64_t);
ngx_mp4_set_64value(atom_header + sizeof(ngx_mp4_atom_header_t),
More information about the nginx-devel
mailing list