]> git.ipfire.org Git - thirdparty/suricata.git/commit
util/base64: fix padding bytes for trailing data
authorShivani Bhardwaj <shivani@oisf.net>
Thu, 30 Mar 2023 07:24:29 +0000 (12:54 +0530)
committerShivani Bhardwaj <shivanib134@gmail.com>
Tue, 25 Jul 2023 14:59:04 +0000 (20:29 +0530)
commitf7b5bda27275b24bcf05872519fb9cc6bd9230b3
treed197171ee24b54ab03f3cbf71bb5291f6ce6e4bb
parent328e2474d3a7394227586952281975d027b32a14
util/base64: fix padding bytes for trailing data

Padding bytes for the last remainder data should be as follows:

Case   |    Remainder bytes     |    Padding
----------------------------------------------
  I    |              1         |      3
  II   |              2         |      2
  III  |              3         |      1

However, we calculate the decoded_bytes with the formula:
decoded_bytes = ASCII_BLOCK - padding

this means for Case I when padding is 3 bytes, the decoded_bytes would
be 0. This is incorrect for any trailing data. In any of the above
cases, if the parsing was successful, there should at least be 1 decoded
byte.

(cherry picked from commit 095c335c72befec2cfcd43390f86d116926bcd17)
src/util-base64.c