BUG/MINOR: tools: Fix loop condition in dump_text()
authorTim Duesterhus <tim@bastelstu.be>
Sat, 28 Aug 2021 22:58:22 +0000 (00:58 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Sep 2021 14:29:14 +0000 (16:29 +0200)
commit5a33a840a157641ff14dce2fe266363762a35a2f
tree737de1d1e484d8185278cf17efe067e187334f27
parent1ee21943ae572bcd9b54353ce2ceed5cb31e6332
BUG/MINOR: tools: Fix loop condition in dump_text()

The condition should first check whether `bsize` is reached, before
dereferencing the offset. Even if this always works fine, due to the
string being null-terminated, this certainly looks odd.

Found using GitHub's CodeQL scan.

This bug traces back to at least 97c2ae13bc0d7961a348102d6719fbcaf34d46d5
(1.7.0+) and this patch should be backported accordingly.

(cherry picked from commit 18795d48a9bb09aedc57e547029828a56322e49d)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit cd5521e7ca7472bf69874603c0c5785d4ff1d1e2)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/tools.c