=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.182 retrieving revision 1.183 diff -c -r1.182 -r1.183 *** src/usr.bin/cvs/file.c 2007/01/29 15:47:39 1.182 --- src/usr.bin/cvs/file.c 2007/01/31 21:07:35 1.183 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.182 2007/01/29 15:47:39 joris Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.183 2007/01/31 21:07:35 xsa Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau *************** *** 71,77 **** void cvs_file_init(void) { ! int i, l; FILE *ifp; size_t len; char path[MAXPATHLEN], buf[MAXNAMLEN]; --- 71,77 ---- void cvs_file_init(void) { ! int i; FILE *ifp; size_t len; char path[MAXPATHLEN], buf[MAXNAMLEN]; *************** *** 84,92 **** 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"); ifp = fopen(path, "r"); if (ifp == NULL) { --- 84,90 ---- cvs_file_ignore(cvs_ign_std[i], &cvs_ign_pats); /* read the cvsignore file in the user's home directory, if any */ ! (void)xsnprintf(path, MAXPATHLEN, "%s/.cvsignore", cvs_homedir); ifp = fopen(path, "r"); if (ifp == NULL) { *************** *** 199,211 **** 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"); for (p = rpath; p[0] == '.' && p[1] == '/';) p += 2; --- 197,206 ---- struct cvs_file * cvs_file_get_cf(const char *d, const char *f, int fd, int type) { struct cvs_file *cf; char *p, rpath[MAXPATHLEN]; ! (void)xsnprintf(rpath, MAXPATHLEN, "%s/%s", d, f); for (p = rpath; p[0] == '.' && p[1] == '/';) p += 2; *************** *** 228,234 **** void cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) { ! int len, fd, type; struct stat st; struct cvs_file *cf; struct cvs_filelist *l, *nxt; --- 223,229 ---- void cvs_file_walklist(struct cvs_flisthead *fl, struct cvs_recursion *cr) { ! int fd, type; struct stat st; struct cvs_file *cf; struct cvs_filelist *l, *nxt; *************** *** 272,281 **** } cvs_get_repository_path(d, repo, MAXPATHLEN); ! len = snprintf(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); --- 267,274 ---- } cvs_get_repository_path(d, repo, MAXPATHLEN); ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", repo, f); if ((fd = open(fpath, O_RDONLY)) == -1) { strlcat(fpath, RCS_FILE_EXT, MAXPATHLEN); *************** *** 357,366 **** * 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, CVS_PATH_CVSDIR); - if (l == -1 || l >= MAXPATHLEN) - fatal("cvs_file_walkdir: overflow"); l = stat(fpath, &st); if (cvs_cmdop != CVS_OP_IMPORT && --- 350,357 ---- * If we do not have a admin directory inside here, dont bother, * unless we are running import. */ ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); l = stat(fpath, &st); if (cvs_cmdop != CVS_OP_IMPORT && *************** *** 371,379 **** /* * 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"); if ((fp = fopen(fpath, "r")) != NULL) { while (fgets(fpath, MAXPATHLEN, fp) != NULL) { --- 362,368 ---- /* * check for a local .cvsignore file */ ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/.cvsignore", cf->file_path); if ((fp = fopen(fpath, "r")) != NULL) { while (fgets(fpath, MAXPATHLEN, fp) != NULL) { *************** *** 420,429 **** continue; } ! l = snprintf(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 --- 409,416 ---- continue; } ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, dp->d_name); /* * nfs and afs will show d_type as DT_UNKNOWN *************** *** 506,515 **** TAILQ_FOREACH(line, &(entlist->cef_ent), entries_list) { ent = cvs_ent_parse(line->buf); ! l = snprintf(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) --- 493,500 ---- TAILQ_FOREACH(line, &(entlist->cef_ent), entries_list) { ent = cvs_ent_parse(line->buf); ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, ent->ce_name); if (!(cr->flags & CR_RECURSE_DIRS) && ent->ce_type == CVS_ENT_DIR) *************** *** 564,570 **** size_t len; struct stat st; BUF *b1, *b2; ! int rflags, l, ismodified, rcsdead; CVSENTRIES *entlist = NULL; const char *state; char repo[MAXPATHLEN], rcsfile[MAXPATHLEN], r1[16], r2[16]; --- 549,555 ---- size_t len; struct stat st; BUF *b1, *b2; ! int rflags, ismodified, rcsdead; CVSENTRIES *entlist = NULL; const char *state; char repo[MAXPATHLEN], rcsfile[MAXPATHLEN], r1[16], r2[16]; *************** *** 577,586 **** } cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); ! l = snprintf(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); --- 562,569 ---- } cvs_get_repository_path(cf->file_wd, repo, MAXPATHLEN); ! (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s", repo, cf->file_name); if (cf->file_type == CVS_FILE) { len = strlcat(rcsfile, RCS_FILE_EXT, MAXPATHLEN); *************** *** 634,643 **** 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", 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) { --- 617,624 ---- fatal("cvs_file_classify: failed to parse RCS"); cf->file_rcs->rf_inattic = 0; } else if (cvs_cmdop != CVS_OP_CHECKOUT) { ! (void)xsnprintf(rcsfile, MAXPATHLEN, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); cf->repo_fd = open(rcsfile, O_RDONLY); if (cf->repo_fd != -1) {