Commit Diff
Diff:
da39935df3ff8a2d8cfc080ddf69352220d6de73
18223c2807bc7cc41327d84c187934fd2730d277
Commit:
18223c2807bc7cc41327d84c187934fd2730d277
Tree:
85760a45d8891b72737348523bda29add85fe547
Author:
Omar Polo <op@omarpolo.com>
Date:
Mon Jun 13 18:01:58 2022 UTC
Message:
reset path buffer before writing to it

otherwise path, which is filled by the garbage that's on the stack, may
not end with a NUL byte. main_enqueue fails with "malformed data" if
the path sent doesn't end with a NUL.

(i.e. the fact that in every case the path is NUL-terminated is not
relevant. For semplicity, I'm working with paths long PATH_MAX bytes
and only checking that path[PATH_MAX-1] is NUL when handling the imsgs.)

Issue reported by Dirk-Wilhelm Peters, thanks!
commit - da39935df3ff8a2d8cfc080ddf69352220d6de73
commit + 18223c2807bc7cc41327d84c187934fd2730d277
blob - 2036dbf365e7a070da18f97ac5d6900620e005d6
blob + d72565ca77eed2dc3b62cb83bd3cdf0883b70e37
--- ctl.c
+++ ctl.c
@@ -203,6 +203,7 @@ load_files(struct parse_result *res, int *ret)
} else if (!strncmp(file, " ", 2))
file += 2;
+ memset(path, 0, sizeof(path));
if (canonpath(file, path, sizeof(path)) == -1) {
log_warnx("canonpath %s", file);
continue;
@@ -320,6 +321,7 @@ ctlaction(struct parse_result *res)
case ADD:
done = 0;
for (i = 0; res->files[i] != NULL; ++i) {
+ memset(path, 0, sizeof(path));
if (canonpath(res->files[i], path, sizeof(path))
== -1) {
log_warn("canonpath %s", res->files[i]);
Omar Polo