diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-04-16 20:05:06 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-04-16 20:05:06 +0000 |
commit | 0e7b2118cbe77c28655ff3e45b9d8a22b724b2ed (patch) | |
tree | 0f63bb5cc0b12b02ed73fc66a73bcc7c8c25bc22 /usr.bin/cvs/init.c | |
parent | 6ea60b1ca8bf98a22c223f177182274b0a6eb78a (diff) |
more snprintf return value check; joris ok
Diffstat (limited to 'usr.bin/cvs/init.c')
-rw-r--r-- | usr.bin/cvs/init.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c index 59946c39c7c..3a9ba588751 100644 --- a/usr.bin/cvs/init.c +++ b/usr.bin/cvs/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.14 2005/04/12 14:58:40 joris Exp $ */ +/* $OpenBSD: init.c,v 1.15 2005/04/16 20:05:05 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -84,14 +84,19 @@ struct cvs_cmd_info cvs_init = { int cvs_init_local(struct cvsroot *root) { - int fd; + int fd, l; u_int i; char path[MAXPATHLEN]; RCSFILE *rfp; for (i = 0; i < sizeof(cvsroot_files)/sizeof(cvsroot_files[i]); i++) { - snprintf(path, sizeof(path), "%s/%s", root->cr_dir, + l = snprintf(path, sizeof(path), "%s/%s", root->cr_dir, cvsroot_files[i].cf_path); + if (l == -1 || l >= (int)sizeof(path)) { + errno = ENAMETOOLONG; + cvs_log(LP_ERRNO, "%s", path); + return (-1); + } if (cvsroot_files[i].cf_type == CFT_DIR) { if (mkdir(path, cvsroot_files[i].cf_mode) == -1) { |