diff options
author | 2005-07-07 15:52:26 +0000 | |
---|---|---|
committer | 2005-07-07 15:52:26 +0000 | |
commit | ce2fed3b4e7b22acb1b3e930478f8ff5be522eaa (patch) | |
tree | 65ff048707bf32b67859be7842c26997065baa70 | |
parent | initialize Scan.SSID from the right source (diff) | |
download | wireguard-openbsd-ce2fed3b4e7b22acb1b3e930478f8ff5be522eaa.tar.xz wireguard-openbsd-ce2fed3b4e7b22acb1b3e930478f8ff5be522eaa.zip |
more snprintf(3) checks, check against the correct
size of the buffer, close RCSFILE on error.
ok xsa@
-rw-r--r-- | usr.bin/cvs/status.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c index 651038c68c7..8febd9f5d0f 100644 --- a/usr.bin/cvs/status.c +++ b/usr.bin/cvs/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.33 2005/07/07 15:10:17 xsa Exp $ */ +/* $OpenBSD: status.c,v 1.34 2005/07/07 15:52:26 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -225,19 +225,28 @@ cvs_status_local(CVSFILE *cf, void *arg) rcsnum_tostr(cf->cf_lrev, buf, sizeof(buf))); } - if (len == -1 || len >= (int)sizeof(len)) + if (len == -1 || len >= (int)sizeof(buf)) { + if (rf != NULL) + rcs_close(rf); return (CVS_EX_DATA); + } cvs_printf(" Working revision:\t%s\n", buf); if (cf->cf_cvstat == CVS_FST_UNKNOWN) { - snprintf(buf, sizeof(buf), "%s", "No revision control file\n"); + len = snprintf(buf, sizeof(buf), "No revision control file\n"); } else { - snprintf(buf, sizeof(buf), "%s\t%s", + len = snprintf(buf, sizeof(buf), "%s\t%s", rcsnum_tostr(rf->rf_head, numbuf, sizeof(numbuf)), rcspath); } + if (len == -1 || len >= (int)sizeof(buf)) { + if (rf != NULL) + rcs_close(rf); + return (CVS_EX_DATA); + } + cvs_printf(" Repository revision:\t%s\n", buf); /* If the file is unknown, no other output is needed after this. */ |