=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/add.c,v retrieving revision 1.73 retrieving revision 1.74 diff -c -r1.73 -r1.74 *** src/usr.bin/cvs/add.c 2007/01/27 21:18:17 1.73 --- src/usr.bin/cvs/add.c 2007/01/31 21:07:35 1.74 *************** *** 1,4 **** ! /* $OpenBSD: add.c,v 1.73 2007/01/27 21:18:17 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2005, 2006 Xavier Santolaria --- 1,4 ---- ! /* $OpenBSD: add.c,v 1.74 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2005, 2006 Xavier Santolaria *************** *** 66,72 **** "invalid RCS keyword expension mode"); fatal("%s", cvs_cmd_add.cmd_synopsis); } ! snprintf(kbuf, sizeof(kbuf), "-k%s", koptstr); break; case 'm': logmsg = xstrdup(optarg); --- 66,72 ---- "invalid RCS keyword expension mode"); fatal("%s", cvs_cmd_add.cmd_synopsis); } ! (void)xsnprintf(kbuf, sizeof(kbuf), "-k%s", koptstr); break; case 'm': logmsg = xstrdup(optarg); *************** *** 120,134 **** 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"); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); --- 120,131 ---- void cvs_add_entry(struct cvs_file *cf) { char entry[CVS_ENT_MAXLINELEN]; CVSENTRIES *entlist; if (cf->file_type == CVS_DIR) { ! (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, ! "D/%s/////", cf->file_name); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, entry); *************** *** 165,180 **** static void add_directory(struct cvs_file *cf) { ! int l, 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"); added = 1; if (stat(entry, &st) != -1) { --- 162,176 ---- static void add_directory(struct cvs_file *cf) { ! 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); ! (void)xsnprintf(entry, MAXPATHLEN, "%s%s", ! cf->file_rpath, RCS_FILE_EXT); added = 1; if (stat(entry, &st) != -1) { *************** *** 216,222 **** entry, tag, date, nb); p = xmalloc(CVS_ENT_MAXLINELEN); ! l = snprintf(p, CVS_ENT_MAXLINELEN, "D/%s/////", cf->file_name); entlist = cvs_ent_open(cf->file_wd); cvs_ent_add(entlist, p); --- 212,218 ---- entry, tag, date, nb); p = xmalloc(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,231 **** } if (added == 1) { ! snprintf(msg, sizeof(msg), "Directory %s added to the repository", cf->file_rpath); if (tag != NULL) { --- 221,227 ---- } if (added == 1) { ! (void)xsnprintf(msg, sizeof(msg), "Directory %s added to the repository", cf->file_rpath); if (tag != NULL) { *************** *** 337,343 **** add_entry(struct cvs_file *cf) { FILE *fp; - int l; char entry[CVS_ENT_MAXLINELEN], path[MAXPATHLEN], revbuf[16], tbuf[32]; CVSENTRIES *entlist; --- 333,338 ---- *************** *** 352,368 **** tbuf[strlen(tbuf) - 1] = '\0'; /* Remove the '-' prefixing the version number. */ ! l = snprintf(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", 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", --- 347,359 ---- tbuf[strlen(tbuf) - 1] = '\0'; /* Remove the '-' prefixing the version number. */ ! (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 : ""); } else { if (logmsg != NULL) { ! (void)xsnprintf(path, MAXPATHLEN, "%s/%s%s", CVS_PATH_CVSDIR, cf->file_name, CVS_DESCR_FILE_EXT); if ((fp = fopen(path, "w+")) == NULL) fatal("add_entry: fopen `%s': %s", *************** *** 376,386 **** (void)fclose(fp); } ! l = snprintf(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); --- 367,375 ---- (void)fclose(fp); } ! (void)xsnprintf(entry, CVS_ENT_MAXLINELEN, "/%s/0/Initial %s/%s/", cf->file_name, cf->file_name, (kflag != RCS_KWEXP_DEFAULT) ? kbuf : ""); } entlist = cvs_ent_open(cf->file_wd);