Opened 5 years ago

Last modified 5 years ago

#7920 new defect

"-strict_mime_boundary 1" doesn't actually apply a strict boundary

Reported by: barsnick Owned by:
Priority: normal Component: avformat
Version: git-master Keywords: mpjpeg
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no


Summary of the bug:
The mpjpegdec option "-strict_mime_boundary 1" doesn't actually apply a strict boundary, as it doesn't find the boundary tag in the "Content-type:" header.

How to reproduce:
You would need a stream which doesn't actually adhere strictly to the boundary specification to notice.

With debug code, you can determine that even if a boundary is given in the "Content-type:" header, mpjpegdec fails to match it and falls back to the non-strict "\r\n--" boundary.

Change History (1)

comment:1 by barsnick, 5 years ago

Root cause is this:

Using the call

  if (!av_stristart(start, "boundary=", &start)) {

the function mpjpeg_get_boundary() tries to match the parameter for the given multipart boundary.

av_stristart(str, pfx, ptr) is documented as:

Return non-zero if pfx is a prefix of str independent of case.

If it is, *ptr is set to the address of the first character in str after the prefix.

So, assuming this call actually matches the "boundary=" parameter check, it returns non-zero. Unfortunately, the code for the good (match) case is checked with !, which means it incorrectly checks for zero. In other words, the ! is misplaced.

Note: See TracTickets for help on using tickets.