diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-04-16 20:31:19 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-04-16 20:31:19 +0000 |
commit | 3a80527a4831c13489ff5240fb472d3445663f51 (patch) | |
tree | 42ef1263750311cbfd1ffdd26f6ad1d70a9a72f7 /usr.bin/cvs | |
parent | 707d3e467aee09957646f6bec04e4a120b9f4b29 (diff) |
thought i had committed that earlier;snprintf return value check; joris ok
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/status.c | 12 | ||||
-rw-r--r-- | usr.bin/cvs/tag.c | 13 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 13 |
3 files changed, 30 insertions, 8 deletions
diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c index 00a38de945f..91d5d5d3a54 100644 --- a/usr.bin/cvs/status.c +++ b/usr.bin/cvs/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.17 2005/04/16 20:26:05 joris Exp $ */ +/* $OpenBSD: status.c,v 1.18 2005/04/16 20:31:18 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -168,6 +168,7 @@ cvs_status_file(CVSFILE *cfp, void *arg) int cvs_status_local(CVSFILE *cfp, void *arg) { + int l; char *repo, buf[MAXNAMLEN], fpath[MAXPATHLEN], rcspath[MAXPATHLEN]; RCSFILE *rf; struct cvs_ent *entp; @@ -187,8 +188,15 @@ cvs_status_local(CVSFILE *cfp, void *arg) return (0); } - snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", + l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", root->cr_dir, repo, CVS_FILE_NAME(cfp), RCS_FILE_EXT); + if (l == -1 || l >= (int)sizeof(rcspath)) { + errno = ENAMETOOLONG; + cvs_log(LP_ERRNO, "%s", rcspath); + + cvs_ent_free(entp); + return (-1); + } rf = rcs_open(rcspath, RCS_READ); if (rf == NULL) { diff --git a/usr.bin/cvs/tag.c b/usr.bin/cvs/tag.c index 964edcb2bd4..6b1c5991375 100644 --- a/usr.bin/cvs/tag.c +++ b/usr.bin/cvs/tag.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tag.c,v 1.11 2005/04/12 14:58:40 joris Exp $ */ +/* $OpenBSD: tag.c,v 1.12 2005/04/16 20:31:18 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2004 Joris Vink <joris@openbsd.org> @@ -155,7 +155,7 @@ cvs_tag_sendflags(struct cvsroot *root) int cvs_tag_file(CVSFILE *cfp, void *arg) { - int ret; + int ret, l; char *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN]; RCSFILE *rf; struct cvs_ent *entp; @@ -206,8 +206,15 @@ cvs_tag_file(CVSFILE *cfp, void *arg) else repo = NULL; - snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", + l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", root->cr_dir, repo, CVS_FILE_NAME(cfp), RCS_FILE_EXT); + if (l == -1 || l >= (int)sizeof(rcspath)) { + errno = ENAMETOOLONG; + cvs_log(LP_ERRNO, "%s", rcspath); + + cvs_ent_free(entp); + return (-1); + } rf = rcs_open(rcspath, RCS_READ); if (rf == NULL) { diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 9556277ddcf..aefe7b0a03a 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.21 2005/04/12 14:58:40 joris Exp $ */ +/* $OpenBSD: update.c,v 1.22 2005/04/16 20:31:18 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -99,7 +99,7 @@ cvs_update_options(char *opt, int argc, char **argv, int *arg) int cvs_update_file(CVSFILE *cf, void *arg) { - int ret; + int ret, l; char *fname, *repo, fpath[MAXPATHLEN], rcspath[MAXPATHLEN]; RCSFILE *rf; struct cvsroot *root; @@ -154,8 +154,15 @@ cvs_update_file(CVSFILE *cf, void *arg) return (0); } - snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", + l = snprintf(rcspath, sizeof(rcspath), "%s/%s/%s%s", root->cr_dir, repo, fname, RCS_FILE_EXT); + if (l == -1 || l >= (int)sizeof(rcspath)) { + errno = ENAMETOOLONG; + cvs_log(LP_ERRNO, "%s", rcspath); + + cvs_ent_free(entp); + return (-1); + } rf = rcs_open(rcspath, RCS_READ); if (rf == NULL) { |