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.
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),