ubase

suckless linux base utils
git clone git://git.suckless.org/ubase
Log | Files | Refs | README | LICENSE

commit 4a324f635986087c8a609687cc7227f95a413fc4
parent 9859943d47552a32438c0a8b2a7f933d30f733f0
Author: sin <sin@2f30.org>
Date:   Mon, 25 Aug 2014 19:14:34 +0100

Check for cmd truncation in watch(1)

Diffstat:
Mwatch.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/watch.c b/watch.c @@ -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\n"); 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\n"); + if (strlcat(cmd, argv[i], sizeof(cmd)) >= sizeof(cmd)) + eprintf("command too long\n"); } for (;;) {