]> git.ipfire.org Git - thirdparty/systemd.git/commit
string-util: improve overflow checking
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Fri, 30 Oct 2020 09:18:04 +0000 (10:18 +0100)
committerRasmus Villemoes <rasmus.villemoes@prevas.dk>
Tue, 3 Nov 2020 13:26:08 +0000 (14:26 +0100)
commit6ced0770c741170a05057dffbf3ef78e46eafe53
tree566174479add2f355806322eef82457cd7aa4f43
parent020003f235ca2e5e7897b4bd1d4a0dba7c463b08
string-util: improve overflow checking

The current overflow checking is broken in the corner case of the strings'
combined length being exactly SIZE_MAX: After the loop, l would be SIZE_MAX,
but we're not testing whether the l+1 expression overflows.

Fix it by simply pre-accounting for the final '\0': initialize l to 1 instead
of 0.
src/basic/string-util.c