=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/file.c,v retrieving revision 1.263 retrieving revision 1.264 diff -c -r1.263 -r1.264 *** src/usr.bin/cvs/file.c 2013/12/13 15:19:41 1.263 --- src/usr.bin/cvs/file.c 2015/01/16 06:40:07 1.264 *************** *** 1,4 **** ! /* $OpenBSD: file.c,v 1.263 2013/12/13 15:19:41 zhuk Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau --- 1,4 ---- ! /* $OpenBSD: file.c,v 1.264 2015/01/16 06:40:07 deraadt Exp $ */ /* * Copyright (c) 2006 Joris Vink * Copyright (c) 2004 Jean-Francois Brousseau *************** *** 89,95 **** { int i; FILE *ifp; ! char path[MAXPATHLEN], buf[MAXNAMLEN]; TAILQ_INIT(&cvs_ign_pats); TAILQ_INIT(&dir_ign_pats); --- 89,95 ---- { int i; FILE *ifp; ! char path[PATH_MAX], buf[MAXNAMLEN]; TAILQ_INIT(&cvs_ign_pats); TAILQ_INIT(&dir_ign_pats); *************** *** 103,109 **** return; /* 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) { --- 103,109 ---- return; /* read the cvsignore file in the user's home directory, if any */ ! (void)xsnprintf(path, PATH_MAX, "%s/.cvsignore", cvs_homedir); ifp = fopen(path, "r"); if (ifp == NULL) { *************** *** 264,270 **** struct stat st; struct cvs_file *cf; struct cvs_filelist *l, *nxt; ! char *d, *f, repo[MAXPATHLEN], fpath[MAXPATHLEN]; for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) { if (cvs_quit) --- 264,270 ---- struct stat st; struct cvs_file *cf; struct cvs_filelist *l, *nxt; ! char *d, *f, repo[PATH_MAX], fpath[PATH_MAX]; for (l = RB_MIN(cvs_flisthead, fl); l != NULL; l = nxt) { if (cvs_quit) *************** *** 311,322 **** goto next; } ! 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); fd = open(fpath, O_RDONLY); } --- 311,322 ---- goto next; } ! cvs_get_repository_path(d, repo, PATH_MAX); ! (void)xsnprintf(fpath, PATH_MAX, "%s/%s", repo, f); if ((fd = open(fpath, O_RDONLY)) == -1) { ! strlcat(fpath, RCS_FILE_EXT, PATH_MAX); fd = open(fpath, O_RDONLY); } *************** *** 362,368 **** if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { cvs_get_repository_path(cf->file_wd, ! repo, MAXPATHLEN); cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO)); } --- 362,368 ---- if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { cvs_get_repository_path(cf->file_wd, ! repo, PATH_MAX); cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO)); } *************** *** 402,408 **** struct cvs_ent_line *line; struct cvs_flisthead fl, dl; CVSENTRIES *entlist; ! char *buf, *ebuf, *cp, repo[MAXPATHLEN], fpath[MAXPATHLEN]; cvs_log(LP_TRACE, "cvs_file_walkdir(%s)", cf->file_path); --- 402,408 ---- struct cvs_ent_line *line; struct cvs_flisthead fl, dl; CVSENTRIES *entlist; ! char *buf, *ebuf, *cp, repo[PATH_MAX], fpath[PATH_MAX]; cvs_log(LP_TRACE, "cvs_file_walkdir(%s)", cf->file_path); *************** *** 429,435 **** * If we do not have an admin directory inside here, dont bother, * unless we are running export or import. */ ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); l = stat(fpath, &st); --- 429,435 ---- * If we do not have an admin directory inside here, dont bother, * unless we are running export or import. */ ! (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, CVS_PATH_CVSDIR); l = stat(fpath, &st); *************** *** 443,452 **** /* * 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) { fpath[strcspn(fpath, "\n")] = '\0'; if (fpath[0] == '\0') continue; --- 443,452 ---- /* * check for a local .cvsignore file */ ! (void)xsnprintf(fpath, PATH_MAX, "%s/.cvsignore", cf->file_path); if ((fp = fopen(fpath, "r")) != NULL) { ! while (fgets(fpath, PATH_MAX, fp) != NULL) { fpath[strcspn(fpath, "\n")] = '\0'; if (fpath[0] == '\0') continue; *************** *** 493,499 **** continue; } ! (void)xsnprintf(fpath, MAXPATHLEN, "%s/%s", cf->file_path, dp->d_name); /* --- 493,499 ---- continue; } ! (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, dp->d_name); /* *************** *** 572,578 **** 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) && --- 572,578 ---- TAILQ_FOREACH(line, &(entlist->cef_ent), entries_list) { ent = cvs_ent_parse(line->buf); ! (void)xsnprintf(fpath, PATH_MAX, "%s/%s", cf->file_path, ent->ce_name); if (!(cr->flags & CR_RECURSE_DIRS) && *************** *** 588,594 **** walkrepo: if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { ! cvs_get_repository_path(cf->file_path, repo, MAXPATHLEN); cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO)); } --- 588,594 ---- walkrepo: if (current_cvsroot->cr_method == CVS_METHOD_LOCAL) { ! cvs_get_repository_path(cf->file_path, repo, PATH_MAX); cvs_repository_lock(repo, (cmdp->cmd_flags & CVS_LOCK_REPO)); } *************** *** 646,652 **** int rflags, ismodified, rcsdead; CVSENTRIES *entlist = NULL; const char *state; ! char repo[MAXPATHLEN], rcsfile[MAXPATHLEN]; cvs_log(LP_TRACE, "cvs_file_classify(%s, %s)", cf->file_path, (tag != NULL) ? tag : "none"); --- 646,652 ---- int rflags, ismodified, rcsdead; CVSENTRIES *entlist = NULL; const char *state; ! char repo[PATH_MAX], rcsfile[PATH_MAX]; cvs_log(LP_TRACE, "cvs_file_classify(%s, %s)", cf->file_path, (tag != NULL) ? tag : "none"); *************** *** 656,668 **** return; } ! 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); ! if (len >= MAXPATHLEN) fatal("cvs_file_classify: truncation"); } --- 656,668 ---- return; } ! cvs_get_repository_path(cf->file_wd, repo, PATH_MAX); ! (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s", repo, cf->file_name); if (cf->file_type == CVS_FILE) { ! len = strlcat(rcsfile, RCS_FILE_EXT, PATH_MAX); ! if (len >= PATH_MAX) fatal("cvs_file_classify: truncation"); } *************** *** 748,754 **** if (cf->file_rcs == NULL) fatal("cvs_file_classify: failed to parse RCS"); } else { ! (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); --- 748,754 ---- if (cf->file_rcs == NULL) fatal("cvs_file_classify: failed to parse RCS"); } else { ! (void)xsnprintf(rcsfile, PATH_MAX, "%s/%s/%s%s", repo, CVS_PATH_ATTIC, cf->file_name, RCS_FILE_EXT); cf->repo_fd = open(rcsfile, O_RDONLY);