summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2006-12-04 09:51:22 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2006-12-04 09:51:22 +0000
commitddac243616996662a06b87177cce803a5c62ffba (patch)
tree2c436cd2c93d1ae30512d22683c8e3e020b5dad3 /usr.bin/cvs
parentd348db3b021a59a09b3d18a071e2369e22743e16 (diff)
snprintf() -> cvs_path_cat()
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/add.c14
-rw-r--r--usr.bin/cvs/config.c10
-rw-r--r--usr.bin/cvs/import.c11
-rw-r--r--usr.bin/cvs/server.c18
4 files changed, 25 insertions, 28 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c
index 4de145ddfda..e0930e5099e 100644
--- a/usr.bin/cvs/add.c
+++ b/usr.bin/cvs/add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: add.c,v 1.61 2006/10/31 15:23:40 xsa Exp $ */
+/* $OpenBSD: add.c,v 1.62 2006/12/04 09:51:21 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -143,10 +143,9 @@ add_directory(struct cvs_file *cf)
/* Let's see if we have any per-directory tags first. */
cvs_parse_tagfile(cf->file_wd, &tag, &date, &nb);
- l = snprintf(entry, MAXPATHLEN, "%s/%s", cf->file_path,
- CVS_PATH_CVSDIR);
- if (l == -1 || l >= MAXPATHLEN)
- fatal("add_directory: overflow");
+ if (cvs_path_cat(cf->file_path, CVS_PATH_CVSDIR,
+ entry, MAXPATHLEN) >= MAXPATHLEN)
+ fatal("add_directory: truncation");
if (stat(entry, &st) != -1) {
if (!S_ISDIR(st.st_mode)) {
@@ -167,8 +166,9 @@ add_directory(struct cvs_file *cf)
cvs_get_repository_name(cf->file_wd, repo,
MAXPATHLEN);
- l = snprintf(entry, MAXPATHLEN, "%s/%s", repo,
- cf->file_name);
+ if (cvs_path_cat(repo, cf->file_name, entry,
+ MAXPATHLEN) >= MAXPATHLEN)
+ fatal("add_directory: truncation");
cvs_mkadmin(cf->file_path, current_cvsroot->cr_dir,
entry, tag, date, nb);
diff --git a/usr.bin/cvs/config.c b/usr.bin/cvs/config.c
index a8ea5756a9b..6ab0011fc99 100644
--- a/usr.bin/cvs/config.c
+++ b/usr.bin/cvs/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.4 2006/06/16 14:07:42 joris Exp $ */
+/* $OpenBSD: config.c,v 1.5 2006/12/04 09:51:21 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -25,7 +25,6 @@
void
cvs_parse_configfile(void)
{
- int i;
FILE *fp;
size_t len;
struct rlimit rl;
@@ -34,10 +33,9 @@ cvs_parse_configfile(void)
cvs_log(LP_TRACE, "cvs_parse_configfile()");
- i = snprintf(fpath, sizeof(fpath), "%s/%s", current_cvsroot->cr_dir,
- CVS_PATH_CONFIG);
- if (i == -1 || i >= (int)sizeof(fpath))
- fatal("cvs_parse_configfile: overflow");
+ if (cvs_path_cat(current_cvsroot->cr_dir, CVS_PATH_CONFIG,
+ fpath, sizeof(fpath)) >= sizeof(fpath))
+ fatal("cvs_parse_configfile: truncation");
if ((fp = fopen(fpath, "r")) == NULL)
fatal("cvs_config_parse: %s: %s",
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index 1e2b7d83ead..81b5eb0abd9 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.55 2006/12/04 09:46:27 xsa Exp $ */
+/* $OpenBSD: import.c,v 1.56 2006/12/04 09:51:21 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -54,7 +54,7 @@ struct cvs_cmd cvs_cmd_import = {
int
cvs_import(int argc, char **argv)
{
- int ch, l;
+ int ch;
char repo[MAXPATHLEN], *arg = ".";
struct cvs_recursion cr;
@@ -88,10 +88,9 @@ cvs_import(int argc, char **argv)
vendor_tag = argv[1];
release_tag = argv[2];
- l = snprintf(repo, sizeof(repo), "%s/%s", current_cvsroot->cr_dir,
- import_repository);
- if (l == -1 || l >= (int)sizeof(repo))
- fatal("cvs_import: overflow");
+ if (cvs_path_cat(current_cvsroot->cr_dir, import_repository,
+ repo, sizeof(repo)) >= sizeof(repo))
+ fatal("cvs_import: truncation");
if (cvs_noexec != 1) {
if (mkdir(repo, 0755) == -1 && errno != EEXIST)
diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c
index 2e31b19eba1..59bd3d0d549 100644
--- a/usr.bin/cvs/server.c
+++ b/usr.bin/cvs/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.40 2006/11/27 16:04:10 xsa Exp $ */
+/* $OpenBSD: server.c,v 1.41 2006/12/04 09:51:21 xsa Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -305,7 +305,7 @@ void
cvs_server_modified(char *data)
{
BUF *bp;
- int fd, l;
+ int fd;
size_t flen;
mode_t fmode;
const char *errstr;
@@ -325,9 +325,9 @@ cvs_server_modified(char *data)
bp = cvs_remote_receive_file(flen);
fpath = xmalloc(MAXPATHLEN);
- l = snprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
- if (l == -1 || l >= MAXPATHLEN)
- fatal("cvs_server_modified: overflow");
+ if (cvs_path_cat(server_currentdir, data, fpath, MAXPATHLEN) >=
+ MAXPATHLEN)
+ fatal("cvs_server_modified: truncation");
if ((fd = open(fpath, O_WRONLY | O_CREAT | O_TRUNC)) == -1)
fatal("cvs_server_modified: %s: %s", fpath, strerror(errno));
@@ -351,16 +351,16 @@ cvs_server_useunchanged(char *data)
void
cvs_server_unchanged(char *data)
{
- int l, fd;
+ int fd;
char *fpath;
CVSENTRIES *entlist;
struct cvs_ent *ent;
struct timeval tv[2];
fpath = xmalloc(MAXPATHLEN);
- l = snprintf(fpath, MAXPATHLEN, "%s/%s", server_currentdir, data);
- if (l == -1 || l >= MAXPATHLEN)
- fatal("cvs_server_unchanged: overflow");
+ if (cvs_path_cat(server_currentdir, data, fpath, MAXPATHLEN) >=
+ MAXPATHLEN)
+ fatal("cvs_server_unchanged: truncation");
if ((fd = open(fpath, O_RDWR | O_CREAT | O_TRUNC)) == -1)
fatal("cvs_server_unchanged: %s: %s", fpath, strerror(errno));