summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2005-04-16 17:50:09 +0000
committerJoris Vink <joris@cvs.openbsd.org>2005-04-16 17:50:09 +0000
commitbac8fca446729e86fec4858051e1a34610a841d3 (patch)
treef37795deae91c76354502b664ee4c48c88abea27 /usr.bin
parent306d2c85cf362a9041b81c448dd0d093d1b05585 (diff)
check snprintf() return value;
from deraadt@ small change by me
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/hist.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.bin/cvs/hist.c b/usr.bin/cvs/hist.c
index 207233b4681..0dd0bfcc445 100644
--- a/usr.bin/cvs/hist.c
+++ b/usr.bin/cvs/hist.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hist.c,v 1.3 2004/12/07 17:10:56 tedu Exp $ */
+/* $OpenBSD: hist.c,v 1.4 2005/04/16 17:50:08 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -277,11 +277,15 @@ static int
cvs_hist_fmt(const struct cvs_hent *ent, char *buf, size_t blen)
{
char numbuf[64];
+ int len;
if (rcsnum_tostr(ent->ch_rev, numbuf, sizeof(numbuf)) == NULL)
return (-1);
- return (snprintf(buf, blen, "%c%8x|%s|%s|%s|%s|%s",
+ len = snprintf(buf, blen, "%c%8x|%s|%s|%s|%s|%s",
ent->ch_event, ent->ch_date, ent->ch_user, ent->ch_curdir,
- ent->ch_repo, numbuf, ent->ch_arg));
+ ent->ch_repo, numbuf, ent->ch_arg);
+ if (len >= (int)blen || len == -1)
+ return (-1);
+ return (len);
}