[hackers] [ubase] Check for cmd truncation in watch(1) || sin
commit 4a324f635986087c8a609687cc7227f95a413fc4
Author: sin <sin_AT_2f30.org>
Date: Mon Aug 25 19:14:34 2014 +0100
Check for cmd truncation in watch(1)
diff --git a/watch.c b/watch.c
index cd4facc..9d8a9ae 100644
--- a/watch.c
+++ b/watch.c
_AT_@ -31,10 +31,13 @@ main(int argc, char *argv[])
if (argc < 1)
usage();
- strlcpy(cmd, argv[0], sizeof(cmd));
+ if (strlcpy(cmd, argv[0], sizeof(cmd)) >= sizeof(cmd))
+ eprintf("command too long
");
for (i = 1; i < argc; i++) {
- strlcat(cmd, " ", sizeof(cmd));
- strlcat(cmd, argv[i], sizeof(cmd));
+ if (strlcat(cmd, " ", sizeof(cmd)) >= sizeof(cmd))
+ eprintf("command too long
");
+ if (strlcat(cmd, argv[i], sizeof(cmd)) >= sizeof(cmd))
+ eprintf("command too long
");
}
for (;;) {
Received on Mon Aug 25 2014 - 20:15:02 CEST
This archive was generated by hypermail 2.3.0
: Mon Aug 25 2014 - 20:24:08 CEST