diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-11 20:25:24 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-04-11 20:25:24 +0000 |
commit | cb8df57f5472d2dfa8976e783dbdedde742376b9 (patch) | |
tree | 81b6c21b5503871f4e9e055176e3cfc162d7b729 /usr.bin | |
parent | 22514951f940ed31d129a74cc365f721908c6812 (diff) |
handle snprintf return value overflow case; ok otto
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/pkill/pkill.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c index c5374f1588f..3d16763768c 100644 --- a/usr.bin/pkill/pkill.c +++ b/usr.bin/pkill/pkill.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pkill.c,v 1.11 2005/03/27 20:56:47 robert Exp $ */ +/* $OpenBSD: pkill.c,v 1.12 2005/04/11 20:25:23 deraadt Exp $ */ /* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */ /*- @@ -38,7 +38,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: pkill.c,v 1.11 2005/03/27 20:56:47 robert Exp $"; +static const char rcsid[] = "$OpenBSD: pkill.c,v 1.12 2005/04/11 20:25:23 deraadt Exp $"; #endif /* !lint */ #include <sys/types.h> @@ -268,7 +268,9 @@ main(int argc, char **argv) ret = snprintf(buf + j, sizeof(buf) - j, pargv[1] != NULL ? "%s " : "%s", pargv[0]); - if (ret > 0) + if (ret >= sizeof(buf) - j) + j += sizeof(buf) - j - 1; + else if (ret > 0) j += ret; pargv++; } |