mozilla/pdf.js — pull request #5154 by Rob--W (2014-08-08 10:45:54+00:00)
Title: AES cipher: make padding optional

In the bad PDF of #5152, there is a block at some point without padding. This can be found by setting a breakpoint at https://github.com/mozilla/pdf.js/blob/669a4d196eb79fb6dd5122adfa17a337f0c5feda/src/core/crypto.js#L981. When the breakpoint is hit for the second time, it consists of a value that is greater than 16. Consequently the outputLength does not match the byte size of the result, and in the loop thereafter, "RangeError: Source is too large" is thrown.

I've fixed this by checking whether the tail is really a padding before removing it from the output.