comparison src/http/modules/ngx_http_mp4_module.c @ 6818:2b2239a1e0d4

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.
author hucongcong <hucong.c@foxmail.com>
date Tue, 22 Nov 2016 13:40:08 +0800
parents b123eae3fd4e
children 99934aade555
comparison
equal deleted inserted replaced
6817:e75e854657ba 6818:2b2239a1e0d4
1227 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0, 1227 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, mp4->file.log, 0,
1228 "mdat new offset @%O:%O", start_offset, atom_data_size); 1228 "mdat new offset @%O:%O", start_offset, atom_data_size);
1229 1229
1230 atom_header = mp4->mdat_atom_header; 1230 atom_header = mp4->mdat_atom_header;
1231 1231
1232 if ((uint64_t) atom_data_size > (uint64_t) 0xffffffff) { 1232 if ((uint64_t) atom_data_size
1233 > (uint64_t) 0xffffffff - sizeof(ngx_mp4_atom_header_t))
1234 {
1233 atom_size = 1; 1235 atom_size = 1;
1234 atom_header_size = sizeof(ngx_mp4_atom_header64_t); 1236 atom_header_size = sizeof(ngx_mp4_atom_header64_t);
1235 ngx_mp4_set_64value(atom_header + sizeof(ngx_mp4_atom_header_t), 1237 ngx_mp4_set_64value(atom_header + sizeof(ngx_mp4_atom_header_t),
1236 sizeof(ngx_mp4_atom_header64_t) + atom_data_size); 1238 sizeof(ngx_mp4_atom_header64_t) + atom_data_size);
1237 } else { 1239 } else {