quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit c20aa17ae842149c0f6d5edaf64b67977b16cd3d
parent 8ec042a1bacde3a54e9ed21d39a84a712a5cabb7
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 22 Jul 2017 12:29:58 +0200

encode(): fix buffer-overflow and NUL terminate it

Diffstat:
quark.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/quark.c b/quark.c @@ -141,7 +141,7 @@ encode(char src[PATH_MAX], char dest[PATH_MAX]) size_t i; char *s; - for (s = src, i = 0; *s; s++) { + for (s = src, i = 0; *s && i < (PATH_MAX - 4); s++) { if (iscntrl(*s) || (unsigned char)*s > 127) { i += snprintf(dest + i, PATH_MAX - i, "%%%02X", (unsigned char)*s); @@ -150,6 +150,7 @@ encode(char src[PATH_MAX], char dest[PATH_MAX]) i++; } } + dest[i] = '\0'; } static enum status