# HG changeset patch # User Roman Arutyunyan <arut@nginx.com> # Date 1541510958 -10800 # Node ID e5069816039b75b1653a4c7c2f982a1ca8d9f9af # Parent bddacdaaec9ef174504899f1528155f84bf60e59 Mp4: fixed reading 64-bit atoms. Previously there was no validation for the size of a 64-bit atom in an mp4 file. This could lead to a CPU hog when the size is 0, or various other problems due to integer underflow when calculating atom data size, including segmentation fault or worker process memory disclosure. diff -r bddacdaaec9e -r e5069816039b src/http/modules/ngx_http_mp4_module.c --- a/src/http/modules/ngx_http_mp4_module.c Wed Oct 31 16:49:40 2018 +0300 +++ b/src/http/modules/ngx_http_mp4_module.c Tue Nov 06 16:29:18 2018 +0300 @@ -942,6 +942,13 @@ atom_size = ngx_mp4_get_64value(atom_header + 8); atom_header_size = sizeof(ngx_mp4_atom_header64_t); + if (atom_size < sizeof(ngx_mp4_atom_header64_t)) { + ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0, + "\"%s\" mp4 atom is too small:%uL", + mp4->file.name.data, atom_size); + return NGX_ERROR; + } + } else { ngx_log_error(NGX_LOG_ERR, mp4->file.log, 0, "\"%s\" mp4 atom is too small:%uL",