diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2006-11-28 14:49:59 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2006-11-28 14:49:59 +0000 |
commit | 7bb3022d99cdfb308fb6eb3adcb6d015184d8497 (patch) | |
tree | 270c690cf5f1052bb8a267c3c89eca1bf2dc6c76 /usr.bin/cvs | |
parent | c1bbfdb684290a583fa9904254cf6b3e76af9237 (diff) |
snprintf() -> cvs_path_cat()
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/repository.c | 22 | ||||
-rw-r--r-- | usr.bin/cvs/util.c | 15 |
2 files changed, 15 insertions, 22 deletions
diff --git a/usr.bin/cvs/repository.c b/usr.bin/cvs/repository.c index 83e73384a45..2afaf0cc3cb 100644 --- a/usr.bin/cvs/repository.c +++ b/usr.bin/cvs/repository.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repository.c,v 1.5 2006/11/10 14:32:44 xsa Exp $ */ +/* $OpenBSD: repository.c,v 1.6 2006/11/28 14:49:58 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -28,14 +28,12 @@ struct cvs_wklhead repo_locks; void cvs_repository_unlock(const char *repo) { - int l; char fpath[MAXPATHLEN]; cvs_log(LP_TRACE, "cvs_repository_unlock(%s)", repo); - l = snprintf(fpath, sizeof(fpath), "%s/%s", repo, CVS_LOCK); - if (l == -1 || l >= (int)sizeof(fpath)) - fatal("cvs_repository_unlock: overflow"); + if (cvs_path_cat(repo, CVS_LOCK, fpath, sizeof(fpath)) >= sizeof(fpath)) + fatal("cvs_repository_unlock: truncation"); /* XXX - this ok? */ cvs_worklist_run(&repo_locks, cvs_worklist_unlink); @@ -44,16 +42,15 @@ cvs_repository_unlock(const char *repo) void cvs_repository_lock(const char *repo) { - int l, i; + int i; struct stat st; char fpath[MAXPATHLEN]; struct passwd *pw; cvs_log(LP_TRACE, "cvs_repository_lock(%s)", repo); - l = snprintf(fpath, sizeof(fpath), "%s/%s", repo, CVS_LOCK); - if (l == -1 || l >= (int)sizeof(fpath)) - fatal("cvs_repository_lock: overflow"); + if (cvs_path_cat(repo, CVS_LOCK, fpath, sizeof(fpath)) >= sizeof(fpath)) + fatal("cvs_repository_unlock: truncation"); for (i = 0; i < CVS_LOCK_TRIES; i++) { if (cvs_quit) @@ -89,7 +86,6 @@ void cvs_repository_getdir(const char *dir, const char *wdir, struct cvs_flisthead *fl, struct cvs_flisthead *dl, int dodirs) { - int l; DIR *dirp; struct dirent *dp; char *s, fpath[MAXPATHLEN]; @@ -110,9 +106,9 @@ cvs_repository_getdir(const char *dir, const char *wdir, if (dodirs == 0 && dp->d_type == DT_DIR) continue; - l = snprintf(fpath, sizeof(fpath), "%s/%s", wdir, dp->d_name); - if (l == -1 || l >= (int)sizeof(fpath)) - fatal("cvs_repository_getdir: overflow"); + if (cvs_path_cat(wdir, dp->d_name, + fpath, sizeof(fpath)) >= sizeof(fpath)) + fatal("cvs_repository_getdir: truncation"); /* * Anticipate the file type for sorting, we do not determine diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index ae322f862b0..3cb3309ad7c 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.91 2006/10/11 22:00:22 thib Exp $ */ +/* $OpenBSD: util.c,v 1.92 2006/11/28 14:49:58 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org> @@ -571,25 +571,22 @@ cvs_hack_time(time_t oldtime, int togmt) void cvs_get_repository_path(const char *dir, char *dst, size_t len) { - int l; char buf[MAXPATHLEN]; cvs_get_repository_name(dir, buf, sizeof(buf)); - l = snprintf(dst, len, "%s/%s", current_cvsroot->cr_dir, buf); - if (l == -1 || l >= (int)len) - fatal("cvs_get_repository_path: overflow"); + if (cvs_path_cat(current_cvsroot->cr_dir, buf, dst, len) >= len) + fatal("cvs_get_repository_path: truncation"); } void cvs_get_repository_name(const char *dir, char *dst, size_t len) { - int l; FILE *fp; char *s, fpath[MAXPATHLEN]; - l = snprintf(fpath, sizeof(fpath), "%s/%s", dir, CVS_PATH_REPOSITORY); - if (l == -1 || l >= (int)sizeof(fpath)) - fatal("cvs_get_repository_name: overflow"); + if (cvs_path_cat(dir, CVS_PATH_REPOSITORY, + fpath, sizeof(fpath)) >= sizeof(fpath)) + fatal("cvs_get_repository_name: truncation"); if ((fp = fopen(fpath, "r")) != NULL) { fgets(dst, len, fp); |