diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-01-31 21:07:37 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2007-01-31 21:07:37 +0000 |
commit | 63034cae876e861e61d3f799f694fd2113f446dc (patch) | |
tree | 754087f08190f74964ce0ff687bfadb2050e2500 /usr.bin | |
parent | 1c54385244a4350800cb127aa83b2aa07cde5234 (diff) |
snprintf() -> xsnprintf()
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/add.c | 35 | ||||
-rw-r--r-- | usr.bin/cvs/checkout.c | 26 | ||||
-rw-r--r-- | usr.bin/cvs/client.c | 41 | ||||
-rw-r--r-- | usr.bin/cvs/commit.c | 23 | ||||
-rw-r--r-- | usr.bin/cvs/diff3.c | 13 | ||||
-rw-r--r-- | usr.bin/cvs/file.c | 45 | ||||
-rw-r--r-- | usr.bin/cvs/import.c | 7 | ||||
-rw-r--r-- | usr.bin/cvs/log.c | 12 | ||||
-rw-r--r-- | usr.bin/cvs/remote.c | 8 | ||||
-rw-r--r-- | usr.bin/cvs/remove.c | 11 | ||||
-rw-r--r-- | usr.bin/cvs/server.c | 17 | ||||
-rw-r--r-- | usr.bin/cvs/status.c | 20 | ||||
-rw-r--r-- | usr.bin/cvs/update.c | 12 |
13 files changed, 85 insertions, 185 deletions
diff --git a/usr.bin/cvs/add.c b/usr.bin/cvs/add.c index 682acfd7dc6..2a2ac747446 100644 --- a/usr.bin/cvs/add.c +++ b/usr.bin/cvs/add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: add.c,v 1.73 2007/01/27 21:18:17 joris Exp $ */ +/* $OpenBSD: add.c,v 1.74 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -66,7 +66,7 @@ cvs_add(int argc, char **argv) "invalid RCS keyword expension mode"); fatal("%s", cvs_cmd_add.cmd_synopsis); } - snprintf(kbuf, sizeof(kbuf), "-k%s", koptstr); + (void)xsnprintf(kbuf, sizeof(kbuf), "-k%s", koptstr); break; case 'm': logmsg = xstrdup(optarg); @@ -120,15 +120,12 @@ cvs_add(int argc, char **argv) void cvs_add_entry(struct cvs_file *cf) { - int l; char entry[CVS_ENT_MAXLINELEN]; CVSENTRIES *entlist; if (cf->file_type == CVS_DIR) { - l = snprintf(entry, CVS_ENT_MAXLINELEN, - "D/%s/////", cf->file_name); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("cvs_add_entry: overflow"); + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, + "D/%s/////", cf->file_name); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); @@ -165,16 +162,15 @@ cvs_add_local(struct cvs_file *cf) static void add_directory(struct cvs_file *cf) { - int l, added, nb; + int added, nb; struct stat st; CVSENTRIES *entlist; char *date, entry[MAXPATHLEN], msg[1024], repo[MAXPATHLEN], *tag, *p; cvs_log(LP_TRACE, "add_directory(%s)", cf->file_path); - l = snprintf(entry, MAXPATHLEN, "%s%s", cf->file_rpath, RCS_FILE_EXT); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_add_local: overflow"); + (void)xsnprintf(entry, MAXPATHLEN, "%s%s", + cf->file_rpath, RCS_FILE_EXT); added = 1; if (stat(entry, &st) != -1) { @@ -216,7 +212,7 @@ add_directory(struct cvs_file *cf) entry, tag, date, nb); p = xmalloc(CVS_ENT_MAXLINELEN); - l = snprintf(p, CVS_ENT_MAXLINELEN, + (void)xsnprintf(p, CVS_ENT_MAXLINELEN, "D/%s/////", cf->file_name); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, p); @@ -225,7 +221,7 @@ add_directory(struct cvs_file *cf) } if (added == 1) { - snprintf(msg, sizeof(msg), + (void)xsnprintf(msg, sizeof(msg), "Directory %s added to the repository", cf->file_rpath); if (tag != NULL) { @@ -337,7 +333,6 @@ static void add_entry(struct cvs_file *cf) { FILE *fp; - int l; char entry[CVS_ENT_MAXLINELEN], path[MAXPATHLEN], revbuf[16], tbuf[32]; CVSENTRIES *entlist; @@ -352,17 +347,13 @@ add_entry(struct cvs_file *cf) tbuf[strlen(tbuf) - 1] = '\0'; /* Remove the '-' prefixing the version number. */ - l = snprintf(entry, CVS_ENT_MAXLINELEN, + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/", cf->file_name, revbuf, tbuf, cf->file_ent->ce_opts ? cf->file_ent->ce_opts : ""); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("add_entry: truncation"); } else { if (logmsg != NULL) { - l = snprintf(path, MAXPATHLEN, "%s/%s%s", + (void)xsnprintf(path, MAXPATHLEN, "%s/%s%s", CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT); - if (l == -1 || l >= MAXPATHLEN) - fatal("add_entry: truncation"); if ((fp = fopen(path, "w+")) == NULL) fatal("add_entry: fopen `%s': %s", @@ -376,11 +367,9 @@ add_entry(struct cvs_file *cf) (void)fclose(fp); } - l = snprintf(entry, CVS_ENT_MAXLINELEN, + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/0/Initial %s/%s/", cf->file_name, cf->file_name, (kflag != RCS_KWEXP_DEFAULT) ? kbuf : ""); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("add_entry: truncation"); } entlist = cvs_ent_open(cf->file_wd); diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c index f46a1094195..1f4d42a8e30 100644 --- a/usr.bin/cvs/checkout.c +++ b/usr.bin/cvs/checkout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checkout.c,v 1.88 2007/01/28 23:39:42 joris Exp $ */ +/* $OpenBSD: checkout.c,v 1.89 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -199,7 +199,7 @@ checkout_repository(const char *repobase, const char *wdbase) void cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int co_flags) { - int kflag, l, oflags, exists; + int kflag, oflags, exists; time_t rcstime; CVSENTRIES *ent; struct timeval tv[2]; @@ -270,21 +270,16 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int co_flags) tbuf[strlen(tbuf) - 1] = '\0'; if (co_flags & CO_MERGE) { - l = snprintf(timebuf, sizeof(timebuf), "Result of merge+%s", + (void)xsnprintf(timebuf, sizeof(timebuf), "Result of merge+%s", tbuf); - if (l == -1 || l >= (int)sizeof(timebuf)) - fatal("cvs_checkout_file: overflow"); } else { strlcpy(timebuf, tbuf, sizeof(timebuf)); } - if (co_flags & CO_SETSTICKY) { - l = snprintf(stickytag, sizeof(stickytag), "T%s", rev); - if (l == -1 || l >= (int)sizeof(stickytag)) - fatal("cvs_checkout_file: overflow"); - } else { + if (co_flags & CO_SETSTICKY) + (void)xsnprintf(stickytag, sizeof(stickytag), "T%s", rev); + else stickytag[0] = '\0'; - } kbuf[0] = '\0'; if (cf->file_ent != NULL) { @@ -293,11 +288,11 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int co_flags) } else if (cf->file_rcs->rf_expand != NULL) { kflag = rcs_kflag_get(cf->file_rcs->rf_expand); if (!(kflag & RCS_KWEXP_DEFAULT)) - snprintf(kbuf, sizeof(kbuf), + (void)xsnprintf(kbuf, sizeof(kbuf), "-k%s", cf->file_rcs->rf_expand); } - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s", + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/%s", cf->file_name, rev, timebuf, kbuf, stickytag); if (cvs_server_active == 0) { @@ -324,10 +319,9 @@ cvs_checkout_file(struct cvs_file *cf, RCSNUM *rnum, int co_flags) if (!(co_flags & CO_COMMIT)) { if (!(co_flags & CO_MERGE)) { - l = snprintf(template, MAXPATHLEN, + (void)xsnprintf(template, MAXPATHLEN, "%s/checkout.XXXXXXXXXX", cvs_tmpdir); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_Checkout_file: overflow"); + rcs_rev_write_stmp(cf->file_rcs, rnum, template, 0); tosend = template; diff --git a/usr.bin/cvs/client.c b/usr.bin/cvs/client.c index d4618d1a678..953ed80cbe7 100644 --- a/usr.bin/cvs/client.c +++ b/usr.bin/cvs/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.56 2007/01/28 02:04:45 joris Exp $ */ +/* $OpenBSD: client.c,v 1.57 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -140,7 +140,6 @@ client_get_supported_responses(void) static void client_check_directory(char *data) { - int l; CVSENTRIES *entlist; char entry[CVS_ENT_MAXLINELEN], *parent, *base; @@ -157,9 +156,7 @@ client_check_directory(char *data) if (!strcmp(parent, ".")) return; - l = snprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", base); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("client_check_directory: overflow"); + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", base); entlist = cvs_ent_open(parent); cvs_ent_add(entlist, entry); @@ -418,7 +415,6 @@ cvs_client_senddir(const char *dir) void cvs_client_sendfile(struct cvs_file *cf) { - int l; size_t len; char rev[16], timebuf[64], sticky[32]; @@ -464,10 +460,8 @@ cvs_client_sendfile(struct cvs_file *cf) sticky[0] = '\0'; if (cf->file_ent->ce_tag != NULL) { - l = snprintf(sticky, sizeof(sticky), "T%s", + (void)xsnprintf(sticky, sizeof(sticky), "T%s", cf->file_ent->ce_tag); - if (l == -1 || l >= (int)sizeof(sticky)) - fatal("cvs_client_sendfile: overflow"); } cvs_client_send_request("Entry /%s/%s%s/%s/%s/%s", @@ -561,7 +555,6 @@ cvs_client_m(char *data) void cvs_client_checkedin(char *data) { - int l; CVSENTRIES *entlist; struct cvs_ent *ent, *newent; char *dir, *e, entry[CVS_ENT_MAXLINELEN], rev[16], timebuf[64]; @@ -582,17 +575,12 @@ cvs_client_checkedin(char *data) timebuf[strlen(timebuf) - 1] = '\0'; sticky[0] = '\0'; - if (ent->ce_tag != NULL) { - l = snprintf(sticky, sizeof(sticky), "T%s", ent->ce_tag); - if (l == -1 || l >= (int)sizeof(sticky)) - fatal("cvs_client_checkedin: overflow"); - } + if (ent->ce_tag != NULL) + (void)xsnprintf(sticky, sizeof(sticky), "T%s", ent->ce_tag); - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s%s/%s/%s/%s", + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s%s/%s/%s/%s", newent->ce_name, (newent->ce_status == CVS_ENT_REMOVED) ? "-" : "", rev, timebuf, ent->ce_opts ? ent->ce_opts : "", sticky); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("cvs_client_checkedin: overflow"); cvs_ent_free(ent); cvs_ent_free(newent); @@ -603,7 +591,7 @@ cvs_client_checkedin(char *data) void cvs_client_updated(char *data) { - int l, fd; + int fd; time_t now; mode_t fmode, mask; size_t flen; @@ -651,10 +639,8 @@ cvs_client_updated(char *data) e = cvs_ent_parse(en); xfree(en); rcsnum_tostr(e->ce_rev, revbuf, sizeof(revbuf)); - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/", e->ce_name, + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s/%s/", e->ce_name, revbuf, timebuf, e->ce_opts ? e->ce_opts : ""); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("cvs_client_updated: overflow"); cvs_ent_free(e); ent = cvs_ent_open(wdir); @@ -885,7 +871,6 @@ cvs_client_clear_sticky(char *data) static void cvs_client_initlog(void) { - int l; u_int i; char *env, *envdup, buf[MAXPATHLEN], fpath[MAXPATHLEN]; char rpath[MAXPATHLEN], *s; @@ -928,7 +913,7 @@ cvs_client_initlog(void) fatal("cvs_client_initlog: truncation"); break; case 'p': - snprintf(fpath, sizeof(fpath), "%d", getpid()); + (void)xsnprintf(fpath, sizeof(fpath), "%d", getpid()); break; case 'u': if ((pwd = getpwuid(getuid())) != NULL) { @@ -956,9 +941,7 @@ cvs_client_initlog(void) } for (i = 0; i < UINT_MAX; i++) { - l = snprintf(fpath, sizeof(fpath), "%s-%d.in", rpath, i); - if (l == -1 || l >= (int)sizeof(fpath)) - fatal("cvs_client_initlog: overflow"); + (void)xsnprintf(fpath, sizeof(fpath), "%s-%d.in", rpath, i); if (stat(fpath, &st) != -1) continue; @@ -977,9 +960,7 @@ cvs_client_initlog(void) } for (i = 0; i < UINT_MAX; i++) { - l = snprintf(fpath, sizeof(fpath), "%s-%d.out", rpath, i); - if (l == -1 || l >= (int)sizeof(fpath)) - fatal("cvs_client_initlog: overflow"); + (void)xsnprintf(fpath, sizeof(fpath), "%s-%d.out", rpath, i); if (stat(fpath, &st) != -1) continue; diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index 0b929a28371..efe1a38ecc2 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.101 2007/01/26 21:48:17 xsa Exp $ */ +/* $OpenBSD: commit.c,v 1.102 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -209,7 +209,7 @@ cvs_commit_local(struct cvs_file *cf) BUF *b, *d; int isnew; RCSNUM *head; - int l, openflags, rcsflags; + int openflags, rcsflags; char rbuf[24], nbuf[24]; CVSENTRIES *entlist; char attic[MAXPATHLEN], repo[MAXPATHLEN], rcsfile[MAXPATHLEN]; @@ -248,10 +248,8 @@ cvs_commit_local(struct cvs_file *cf) "to be dead", cf->file_path); cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); - l = snprintf(rcsfile, MAXPATHLEN, "%s/%s%s", + (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s%s", repo, cf->file_name, RCS_FILE_EXT); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_commit_local: overflow"); if (rename(cf->file_rpath, rcsfile) == -1) fatal("cvs_commit_local: failed to move %s " @@ -358,17 +356,14 @@ cvs_commit_local(struct cvs_file *cf) cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); - l = snprintf(attic, MAXPATHLEN, "%s/%s", repo, CVS_PATH_ATTIC); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_commit_local: overflow"); + (void)xsnprintf(attic, MAXPATHLEN, "%s/%s", + repo, CVS_PATH_ATTIC); if (mkdir(attic, 0755) == -1 && errno != EEXIST) fatal("cvs_commit_local: failed to create Attic"); - l = snprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo, + (void)xsnprintf(attic, MAXPATHLEN, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_commit_local: overflow"); if (rename(cf->file_rpath, attic) == -1) fatal("cvs_commit_local: failed to move %s to Attic", @@ -425,13 +420,11 @@ static void commit_desc_set(struct cvs_file *cf) { BUF *bp; - int l, fd; + int fd; char desc_path[MAXPATHLEN], *desc; - l = snprintf(desc_path, MAXPATHLEN, "%s/%s%s", + (void)xsnprintf(desc_path, MAXPATHLEN, "%s/%s%s", CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT); - if (l == -1 || l >= MAXPATHLEN) - fatal("commit_desc_set: overflow"); if ((fd = open(desc_path, O_RDONLY)) == -1) return; diff --git a/usr.bin/cvs/diff3.c b/usr.bin/cvs/diff3.c index 9d2718a0a4b..1b2c81ede28 100644 --- a/usr.bin/cvs/diff3.c +++ b/usr.bin/cvs/diff3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diff3.c,v 1.33 2007/01/28 02:04:45 joris Exp $ */ +/* $OpenBSD: diff3.c,v 1.34 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -72,7 +72,7 @@ static const char copyright[] = #ifndef lint static const char rcsid[] = - "$OpenBSD: diff3.c,v 1.33 2007/01/28 02:04:45 joris Exp $"; + "$OpenBSD: diff3.c,v 1.34 2007/01/31 21:07:35 xsa Exp $"; #endif /* not lint */ #include "includes.h" @@ -276,13 +276,8 @@ diff3_internal(int argc, char **argv, const char *fmark, const char *rmark) if (argc < 5) return (-1); - i = snprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", fmark); - if (i < 0 ||i >= (int)sizeof(f1mark)) - fatal("diff3_internal: truncation"); - - i = snprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", rmark); - if (i < 0 ||i >= (int)sizeof(f3mark)) - fatal("diff3_internal: truncation"); + (void)xsnprintf(f1mark, sizeof(f1mark), "<<<<<<< %s", fmark); + (void)xsnprintf(f3mark, sizeof(f3mark), ">>>>>>> %s", rmark); increase(); m = readin(argv[0], &d13); diff --git a/usr.bin/cvs/file.c b/usr.bin/cvs/file.c index 0ae621be3d4..3868efb286d 100644 --- a/usr.bin/cvs/file.c +++ b/usr.bin/cvs/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.182 2007/01/29 15:47:39 joris Exp $ */ +/* $OpenBSD: file.c,v 1.183 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -71,7 +71,7 @@ struct ignore_head dir_ign_pats; void cvs_file_init(void) { - int i, l; + int i; FILE *ifp; size_t len; char path[MAXPATHLEN], buf[MAXNAMLEN]; @@ -84,9 +84,7 @@ cvs_file_init(void) cvs_file_ignore(cvs_ign_std[i], &cvs_ign_pats); /* read the cvsignore file in the user's home directory, if any */ - l = snprintf(path, MAXPATHLEN, "%s/.cvsignore", cvs_homedir); - if (l == -1 || l >= MAXPATHLEN) - fatal("overflow in cvs_file_init"); + (void)xsnprintf(path, MAXPATHLEN, "%s/.cvsignore", cvs_homedir); ifp = fopen(path, "r"); if (ifp == NULL) { @@ -199,13 +197,10 @@ cvs_file_get(const char *name, struct cvs_flisthead *fl) struct cvs_file * cvs_file_get_cf(const char *d, const char *f, int fd, int type) { - int l; struct cvs_file *cf; char *p, rpath[MAXPATHLEN]; - l = snprintf(rpath, MAXPATHLEN, "%s/%s", d, f); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_get_cf: overflow"); + (void)xsnprintf(rpath, MAXPATHLEN, "%s/%s", d, f); for (p = rpath; p[0] == '.' && p[1] == '/';) p += 2; @@ -228,7 +223,7 @@ cvs_file_get_cf(const char *d, const char *f, int fd, int type) void cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) { - int len, fd, type; + int fd, type; struct stat st; struct cvs_file *cf; struct cvs_filelist *l, *nxt; @@ -272,10 +267,8 @@ cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) } cvs_get_repository_path(d, repo, MAXPATHLEN); - len = snprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, f); - if (len == -1 || len >= MAXPATHLEN) - fatal("cvs_file_walklist: overflow"); if ((fd = open(fpath, O_RDONLY)) == -1) { strlcat(fpath, RCS_FILE_EXT, MAXPATHLEN); @@ -357,10 +350,8 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) * If we do not have a admin directory inside here, dont bother, * unless we are running import. */ - l = snprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_walkdir: overflow"); l = stat(fpath, &st); if (cvs_cmdop != CVS_OP_IMPORT && @@ -371,9 +362,7 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) /* * check for a local .cvsignore file */ - l = snprintf(fpath, MAXPATHLEN, "%s/.cvsignore", cf->file_path); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_walkdir: overflow"); + (void)xsnprintf(fpath, MAXPATHLEN, "%s/.cvsignore", cf->file_path); if ((fp = fopen(fpath, "r")) != NULL) { while (fgets(fpath, MAXPATHLEN, fp) != NULL) { @@ -420,10 +409,8 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) continue; } - l = snprintf(fpath, MAXPATHLEN, "%s/%s", + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, dp->d_name); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_walkdir: overflow"); /* * nfs and afs will show d_type as DT_UNKNOWN @@ -506,10 +493,8 @@ cvs_file_walkdir(struct cvs_file *cf, struct cvs_recursion *cr) TAILQ_FOREACH(line, &(entlist->cef_ent), entries_list) { ent = cvs_ent_parse(line->buf); - l = snprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, + (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, ent->ce_name); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_walkdir: overflow"); if (!(cr->flags & CR_RECURSE_DIRS) && ent->ce_type == CVS_ENT_DIR) @@ -564,7 +549,7 @@ cvs_file_classify(struct cvs_file *cf, const char *tag, int loud) size_t len; struct stat st; BUF *b1, *b2; - int rflags, l, ismodified, rcsdead; + int rflags, ismodified, rcsdead; CVSENTRIES *entlist = NULL; const char *state; char repo[MAXPATHLEN], rcsfile[MAXPATHLEN], r1[16], r2[16]; @@ -577,10 +562,8 @@ cvs_file_classify(struct cvs_file *cf, const char *tag, int loud) } cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); - l = snprintf(rcsfile, MAXPATHLEN, "%s/%s", + (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s", repo, cf->file_name); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_classify: overflow"); if (cf->file_type == CVS_FILE) { len = strlcat(rcsfile, RCS_FILE_EXT, MAXPATHLEN); @@ -634,10 +617,8 @@ cvs_file_classify(struct cvs_file *cf, const char *tag, int loud) fatal("cvs_file_classify: failed to parse RCS"); cf->file_rcs->rf_inattic = 0; } else if (cvs_cmdop != CVS_OP_CHECKOUT) { - l = snprintf(rcsfile, MAXPATHLEN, "%s/%s/%s%s", + (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_classify: overflow"); cf->repo_fd = open(rcsfile, O_RDONLY); if (cf->repo_fd != -1) { diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c index d156b4ccb49..c9561a082a8 100644 --- a/usr.bin/cvs/import.c +++ b/usr.bin/cvs/import.c @@ -1,4 +1,4 @@ -/* $OpenBSD: import.c,v 1.66 2007/01/20 01:07:51 niallo Exp $ */ +/* $OpenBSD: import.c,v 1.67 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -145,7 +145,6 @@ cvs_import(int argc, char **argv) void cvs_import_local(struct cvs_file *cf) { - int l; int isnew; struct stat st; char repo[MAXPATHLEN]; @@ -172,11 +171,9 @@ cvs_import_local(struct cvs_file *cf) } isnew = 1; - l = snprintf(repo, sizeof(repo), "%s/%s/%s/%s%s", + (void)xsnprintf(repo, sizeof(repo), "%s/%s/%s/%s%s", current_cvsroot->cr_dir, cf->file_wd, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); - if (l == -1 || l >= (int)sizeof(repo)) - fatal("import_new: overflow"); if (cf->file_rcs != NULL || stat(repo, &st) != -1) isnew = 0; diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c index 1f46dc16e61..18f89a2fa7e 100644 --- a/usr.bin/cvs/log.c +++ b/usr.bin/cvs/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.36 2006/07/07 17:37:17 joris Exp $ */ +/* $OpenBSD: log.c,v 1.37 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -90,17 +90,17 @@ cvs_vlog(u_int level, const char *fmt, va_list vap) prefix[0] = 'C'; } else if (cvs_command != NULL) { if (level == LP_ABORT) - snprintf(prefix, sizeof(prefix), "%s [%s aborted]", - __progname, cmdname); + (void)xsnprintf(prefix, sizeof(prefix), + "%s [%s aborted]", __progname, cmdname); else - snprintf(prefix, sizeof(prefix), "%s %s", __progname, - cmdname); + (void)xsnprintf(prefix, sizeof(prefix), "%s %s", + __progname, cmdname); } else /* just use the standard strlcpy */ strlcpy(prefix, __progname, sizeof(prefix)); vsnprintf(buf, sizeof(buf), fmt, vap); if (level == LP_ERRNO) { - snprintf(ebuf, sizeof(ebuf), ": %s", strerror(errno)); + (void)xsnprintf(ebuf, sizeof(ebuf), ": %s", strerror(errno)); strlcat(buf, ebuf, sizeof(buf)); } diff --git a/usr.bin/cvs/remote.c b/usr.bin/cvs/remote.c index e03a8d55afb..01066ae2f1e 100644 --- a/usr.bin/cvs/remote.c +++ b/usr.bin/cvs/remote.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remote.c,v 1.12 2007/01/26 11:19:44 joris Exp $ */ +/* $OpenBSD: remote.c,v 1.13 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -151,7 +151,7 @@ cvs_remote_receive_file(int fd, size_t len) void cvs_remote_send_file(const char *path) { - int l, fd; + int fd; FILE *out, *in; size_t ret, rw; off_t total; @@ -172,9 +172,7 @@ cvs_remote_send_file(const char *path) cvs_modetostr(st.st_mode, buf, sizeof(buf)); cvs_remote_output(buf); - l = snprintf(buf, sizeof(buf), "%lld", st.st_size); - if (l == -1 || l >= (int)sizeof(buf)) - fatal("cvs_remote_send_file: overflow"); + (void)xsnprintf(buf, sizeof(buf), "%lld", st.st_size); cvs_remote_output(buf); if ((in = fdopen(fd, "r")) == NULL) diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c index 1699b896915..18684b90dfe 100644 --- a/usr.bin/cvs/remove.c +++ b/usr.bin/cvs/remove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remove.c,v 1.61 2007/01/27 20:23:26 joris Exp $ */ +/* $OpenBSD: remove.c,v 1.62 2007/01/31 21:07:36 xsa Exp $ */ /* * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> * @@ -133,7 +133,6 @@ cvs_remove_force(struct cvs_file *cf) void cvs_remove_local(struct cvs_file *cf) { - int l; CVSENTRIES *entlist; char *entry, buf[MAXPATHLEN], tbuf[32], rbuf[16]; @@ -166,11 +165,9 @@ cvs_remove_local(struct cvs_file *cf) cvs_ent_remove(entlist, cf->file_name); cvs_ent_close(entlist, ENT_SYNC); - l = snprintf(buf, sizeof(buf), "%s/%s/%s%s", + (void)xsnprintf(buf, sizeof(buf), "%s/%s/%s%s", cf->file_path, CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT); - if (l == -1 || l >= (int)sizeof(buf)) - fatal("cvs_remove_local: overflow"); (void)unlink(buf); @@ -195,10 +192,8 @@ cvs_remove_local(struct cvs_file *cf) tbuf[strlen(tbuf) - 1] = '\0'; entry = xmalloc(CVS_ENT_MAXLINELEN); - l = snprintf(entry, CVS_ENT_MAXLINELEN, + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/-%s/%s//", cf->file_name, rbuf, tbuf); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("cvs_remove_local: overflow"); if (cvs_server_active == 1) { cvs_server_update_entry("Checked-in", cf); diff --git a/usr.bin/cvs/server.c b/usr.bin/cvs/server.c index 5102103b41b..985cc680dd2 100644 --- a/usr.bin/cvs/server.c +++ b/usr.bin/cvs/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.52 2007/01/26 11:19:44 joris Exp $ */ +/* $OpenBSD: server.c,v 1.53 2007/01/31 21:07:36 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -81,17 +81,14 @@ struct cvs_cmd cvs_cmd_server = { int cvs_server(int argc, char **argv) { - int l; char *cmd, *data; struct cvs_req *req; server_argv[0] = xstrdup("server"); cvs_server_path = xmalloc(MAXPATHLEN); - l = snprintf(cvs_server_path, MAXPATHLEN, "%s/cvs-serv%d", + (void)xsnprintf(cvs_server_path, MAXPATHLEN, "%s/cvs-serv%d", cvs_tmpdir, getpid()); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_server: overflow in server path"); if (mkdir(cvs_server_path, 0700) == -1) fatal("failed to create temporary server directory: %s, %s", @@ -291,7 +288,6 @@ cvs_server_set(char *data) void cvs_server_directory(char *data) { - int l; CVSENTRIES *entlist; char *dir, *repo, *parent, entry[CVS_ENT_MAXLINELEN], *dirn, *p; @@ -325,9 +321,7 @@ cvs_server_directory(char *data) if (strcmp(parent, ".")) { entlist = cvs_ent_open(parent); - l = snprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", dirn); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("cvs_server_directory: overflow"); + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", dirn); cvs_ent_add(entlist, entry); cvs_ent_close(entlist, ENT_SYNC); @@ -611,15 +605,12 @@ cvs_server_version(char *data) void cvs_server_update_entry(const char *resp, struct cvs_file *cf) { - int l; char *p, response[MAXPATHLEN]; if ((p = strrchr(cf->file_rpath, ',')) != NULL) *p = '\0'; - l = snprintf(response, MAXPATHLEN, "%s %s/", resp, cf->file_wd); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_server_update_entry: overflow"); + (void)xsnprintf(response, MAXPATHLEN, "%s %s/", resp, cf->file_wd); cvs_server_send_response("%s", response); cvs_remote_output(cf->file_rpath); diff --git a/usr.bin/cvs/status.c b/usr.bin/cvs/status.c index 5222f2bbc10..3e5f9ced472 100644 --- a/usr.bin/cvs/status.c +++ b/usr.bin/cvs/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.70 2007/01/12 19:28:12 joris Exp $ */ +/* $OpenBSD: status.c,v 1.71 2007/01/31 21:07:36 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2005, 2006 Xavier Santolaria <xsa@openbsd.org> @@ -116,7 +116,6 @@ cvs_status(int argc, char **argv) void cvs_status_local(struct cvs_file *cf) { - int l; size_t len; RCSNUM *head; const char *status; @@ -143,9 +142,8 @@ cvs_status_local(struct cvs_file *cf) if (cf->file_status == FILE_LOST || cf->file_status == FILE_UNKNOWN || (cf->file_rcs != NULL && cf->file_rcs->rf_inattic == 1)) { - l = snprintf(buf, sizeof(buf), "no file %s\t", cf->file_name); - if (l == -1 || l >= (int)sizeof(buf)) - fatal("cvs_status_local: overflow"); + (void)xsnprintf(buf, sizeof(buf), "no file %s\t", + cf->file_name); } else if (strlcpy(buf, cf->file_name, sizeof(buf)) >= sizeof(buf)) fatal("cvs_status_local: overflow"); @@ -153,10 +151,8 @@ cvs_status_local(struct cvs_file *cf) cvs_printf("File: %-17s\tStatus: %s\n\n", buf, status); if (cf->file_ent == NULL) { - l = snprintf(buf, sizeof(buf), + (void)xsnprintf(buf, sizeof(buf), "No entry for %s", cf->file_name); - if (l == -1 || l >= (int)sizeof(buf)) - fatal("cvs_status_local: overflow"); } else if (cf->file_status == FILE_ADDED) { len = strlcpy(buf, "New file!", sizeof(buf)); if (len >= sizeof(buf)) @@ -175,9 +171,7 @@ cvs_status_local(struct cvs_file *cf) fatal("cvs_status_local: truncation"); } - l = snprintf(buf, sizeof(buf), "%s\t%s", revbuf, timebuf); - if (l == -1 || l >= (int)sizeof(buf)) - fatal("cvs_status_local: overflow"); + (void)xsnprintf(buf, sizeof(buf), "%s\t%s", revbuf, timebuf); } cvs_printf(" Working revision:\t%s\n", buf); @@ -191,10 +185,8 @@ cvs_status_local(struct cvs_file *cf) head = rcs_head_get(cf->file_rcs); rcsnum_tostr(head, revbuf, sizeof(revbuf)); rcsnum_free(head); - l = snprintf(buf, sizeof(buf), "%s\t%s", revbuf, + (void)xsnprintf(buf, sizeof(buf), "%s\t%s", revbuf, cf->file_rpath); - if (l == -1 || l >= (int)sizeof(buf)) - fatal("cvs_status_local: overflow"); } cvs_printf(" Repository revision:\t%s\n", buf); diff --git a/usr.bin/cvs/update.c b/usr.bin/cvs/update.c index 28510c5b7a2..1ebd936ac96 100644 --- a/usr.bin/cvs/update.c +++ b/usr.bin/cvs/update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: update.c,v 1.91 2007/01/28 23:37:29 joris Exp $ */ +/* $OpenBSD: update.c,v 1.92 2007/01/31 21:07:36 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * @@ -140,7 +140,6 @@ cvs_update(int argc, char **argv) void cvs_update_enterdir(struct cvs_file *cf) { - int l; char *entry; CVSENTRIES *entlist; @@ -155,10 +154,8 @@ cvs_update_enterdir(struct cvs_file *cf) cf->file_path, strerror(errno)); entry = xmalloc(CVS_ENT_MAXLINELEN); - l = snprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "D/%s////", cf->file_name); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("cvs_update_enterdir: overflow"); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); @@ -367,7 +364,6 @@ cvs_update_local(struct cvs_file *cf) static void update_clear_conflict(struct cvs_file *cf) { - int l; time_t now; CVSENTRIES *entlist; char *entry, revbuf[16], timebuf[32]; @@ -382,10 +378,8 @@ update_clear_conflict(struct cvs_file *cf) rcsnum_tostr(cf->file_ent->ce_rev, revbuf, sizeof(revbuf)); entry = xmalloc(CVS_ENT_MAXLINELEN); - l = snprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//", + (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/%s/%s//", cf->file_name, revbuf, timebuf); - if (l == -1 || l >= CVS_ENT_MAXLINELEN) - fatal("update_clear_conflict: overflow"); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); |