=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/Attic/resp.c,v retrieving revision 1.66 retrieving revision 1.67 diff -c -r1.66 -r1.67 *** src/usr.bin/cvs/Attic/resp.c 2005/12/29 21:28:26 1.66 --- src/usr.bin/cvs/Attic/resp.c 2005/12/30 16:47:36 1.67 *************** *** 1,4 **** ! /* $OpenBSD: resp.c,v 1.66 2005/12/29 21:28:26 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: resp.c,v 1.67 2005/12/30 16:47:36 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 336,343 **** char rpath[MAXPATHLEN], statpath[MAXPATHLEN]; /* remote directory line */ ! if (cvs_getln(root, rpath, sizeof(rpath)) < 0) ! return (-1); STRIP_SLASH(line); --- 336,342 ---- char rpath[MAXPATHLEN], statpath[MAXPATHLEN]; /* remote directory line */ ! cvs_getln(root, rpath, sizeof(rpath)); STRIP_SLASH(line); *************** *** 387,394 **** char buf[MAXPATHLEN]; /* get the remote path */ ! if (cvs_getln(root, buf, sizeof(buf)) < 0) ! return (-1); STRIP_SLASH(line); --- 386,392 ---- char buf[MAXPATHLEN]; /* get the remote path */ ! cvs_getln(root, buf, sizeof(buf)); STRIP_SLASH(line); *************** *** 501,512 **** struct cvs_ent *ent; /* get the remote path */ ! if (cvs_getln(root, entbuf, sizeof(entbuf)) < 0) ! return (-1); /* get the new Entries line */ ! if (cvs_getln(root, entbuf, sizeof(entbuf)) < 0) ! return (-1); if (resp_check_dir(root, line) < 0) return (-1); --- 499,508 ---- struct cvs_ent *ent; /* get the remote path */ ! cvs_getln(root, entbuf, sizeof(entbuf)); /* get the new Entries line */ ! cvs_getln(root, entbuf, sizeof(entbuf)); if (resp_check_dir(root, line) < 0) return (-1); *************** *** 569,601 **** cvs_resp_copyfile(struct cvsroot *root, int type, char *line) { int len; ! char path[MAXPATHLEN], newpath[MAXPATHLEN], newname[MAXNAMLEN], *file; /* read the remote path of the file to copy and its new name */ ! if ((cvs_getln(root, path, sizeof(path)) < 0) || ! (cvs_getln(root, newname, sizeof(newname)) < 0)) ! return (-1); ! if ((file = basename(path)) == NULL) { ! cvs_log(LP_ERR, "no base file name in Copy-file path"); ! return (-1); ! } len = snprintf(path, sizeof(path), "%s%s", line, file); ! if (len == -1 || len >= (int)sizeof(path)) { ! cvs_log(LP_ERR, "source path overflow in Copy-file response"); ! return (-1); ! } len = snprintf(newpath, sizeof(newpath), "%s%s", line, newname); ! if (len == -1 || len >= (int)sizeof(path)) { ! cvs_log(LP_ERR, ! "destination path overflow in Copy-file response"); ! return (-1); ! } if (rename(path, newpath) == -1) { ! cvs_log(LP_ERRNO, "failed to rename %s to %s", path, newpath); ! return (-1); } return (0); --- 565,591 ---- cvs_resp_copyfile(struct cvsroot *root, int type, char *line) { int len; ! char path[MAXPATHLEN], newpath[MAXPATHLEN]; ! char newname[MAXNAMLEN], *file; /* read the remote path of the file to copy and its new name */ ! cvs_getln(root, path, sizeof(path)); ! cvs_getln(root, newname, sizeof(newname)); ! if ((file = basename(path)) == NULL) ! fatal("no base file name in Copy-file path"); len = snprintf(path, sizeof(path), "%s%s", line, file); ! if (len == -1 || len >= (int)sizeof(path)) ! fatal("source path overflow in Copy-file response"); ! len = snprintf(newpath, sizeof(newpath), "%s%s", line, newname); ! if (len == -1 || len >= (int)sizeof(path)) ! fatal("destination path overflow in Copy-file response"); if (rename(path, newpath) == -1) { ! fatal("failed to rename %s to %s: %s", ! path, newpath, strerror(errno)); } return (0); *************** *** 636,655 **** STRIP_SLASH(line); /* read the remote path of the file */ ! if (cvs_getln(root, path, sizeof(path)) < 0) ! return (-1); /* read the new entry */ ! if (cvs_getln(root, path, sizeof(path)) < 0) ! return (-1); if ((ent = cvs_ent_parse(path)) == NULL) return (-1); ret = snprintf(path, sizeof(path), "%s/%s", line, ent->ce_name); ! if (ret == -1 || ret >= (int)sizeof(path)) { ! cvs_log(LP_ERR, "Entries path overflow in response"); ! return (-1); ! } ret = 0; /* --- 626,643 ---- STRIP_SLASH(line); /* read the remote path of the file */ ! cvs_getln(root, path, sizeof(path)); /* read the new entry */ ! cvs_getln(root, path, sizeof(path)); if ((ent = cvs_ent_parse(path)) == NULL) return (-1); + ret = snprintf(path, sizeof(path), "%s/%s", line, ent->ce_name); ! if (ret == -1 || ret >= (int)sizeof(path)) ! fatal("Entries path overflow in response"); ! ret = 0; /* *************** *** 675,687 **** } } ! if (cvs_ent_add(cvs_resp_lastent, ent) < 0) { ! cvs_ent_free(ent); ! return (-1); ! } ! if ((fbuf = cvs_recvfile(root, &fmode)) == NULL) ! return (-1); cvs_buf_write(fbuf, path, fmode); cvs_buf_free(fbuf); --- 663,671 ---- } } ! cvs_ent_add(cvs_resp_lastent, ent); ! fbuf = cvs_recvfile(root, &fmode); cvs_buf_write(fbuf, path, fmode); cvs_buf_free(fbuf); *************** *** 727,744 **** cvs_resp_removed(struct cvsroot *root, int type, char *line) { int l; ! char buf[MAXPATHLEN], base[MAXPATHLEN], fpath[MAXPATHLEN], *file; ! if (cvs_getln(root, buf, sizeof(buf)) < 0) ! return (-1); cvs_splitpath(buf, base, sizeof(base), &file); l = snprintf(fpath, sizeof(fpath), "%s/%s", line, file); ! if (l == -1 || l >= (int)sizeof(fpath)) { ! errno = ENAMETOOLONG; ! cvs_log(LP_ERRNO, "%s", fpath); ! return (-1); ! } if (resp_check_dir(root, line) < 0) return (-1); --- 711,725 ---- cvs_resp_removed(struct cvsroot *root, int type, char *line) { int l; ! char buf[MAXPATHLEN], base[MAXPATHLEN]; ! char fpath[MAXPATHLEN], *file; ! cvs_getln(root, buf, sizeof(buf)); cvs_splitpath(buf, base, sizeof(base), &file); l = snprintf(fpath, sizeof(fpath), "%s/%s", line, file); ! if (l == -1 || l >= (int)sizeof(fpath)) ! fatal("cvs_resp_removed: overflow in path"); if (resp_check_dir(root, line) < 0) return (-1); *************** *** 762,771 **** static int cvs_resp_mode(struct cvsroot *root, int type, char *line) { ! if (cvs_strtomode(line, &cvs_lastmode) < 0) { ! cvs_log(LP_ERR, "error handling Mode response"); ! return (-1); ! } return (0); } --- 743,749 ---- static int cvs_resp_mode(struct cvsroot *root, int type, char *line) { ! cvs_strtomode(line, &cvs_lastmode); return (0); } *************** *** 799,819 **** struct cvs_ent *ent; /* get remote path and build local path of file to be patched */ ! if (cvs_getln(root, buf, sizeof(buf)) < 0) ! return (-1); fname = strrchr(buf, '/'); if (fname == NULL) fname = buf; len = snprintf(file, sizeof(file), "%s%s", line, fname); ! if (len == -1 || len >= (int)sizeof(file)) { ! cvs_log(LP_ERR, "path overflow in Rcs-diff response"); ! return (-1); ! } /* get updated entry fields */ ! if (cvs_getln(root, buf, sizeof(buf)) < 0) ! return (-1); ent = cvs_ent_parse(buf); if (ent == NULL) --- 777,793 ---- struct cvs_ent *ent; /* get remote path and build local path of file to be patched */ ! cvs_getln(root, buf, sizeof(buf)); fname = strrchr(buf, '/'); if (fname == NULL) fname = buf; len = snprintf(file, sizeof(file), "%s%s", line, fname); ! if (len == -1 || len >= (int)sizeof(file)) ! fatal("path overflow in Rcs-diff response"); /* get updated entry fields */ ! cvs_getln(root, buf, sizeof(buf)); ent = cvs_ent_parse(buf); if (ent == NULL) *************** *** 872,879 **** BUF *tmpl; tmpl = cvs_recvfile(root, &mode); ! if (tmpl == NULL) ! return (-1); return (0); } --- 846,852 ---- BUF *tmpl; tmpl = cvs_recvfile(root, &mode); ! cvs_buf_free(tmpl); return (0); } *************** *** 895,901 **** */ l = snprintf(cvspath, sizeof(cvspath), "%s/%s", dir, CVS_PATH_CVSDIR); if (l == -1 || l >= (int)sizeof(cvspath)) ! return (-1); if (stat(cvspath, &st) == -1) { if (errno != ENOENT) --- 868,874 ---- */ l = snprintf(cvspath, sizeof(cvspath), "%s/%s", dir, CVS_PATH_CVSDIR); if (l == -1 || l >= (int)sizeof(cvspath)) ! fatal("resp_check_dir: path overflow"); if (stat(cvspath, &st) == -1) { if (errno != ENOENT) *************** *** 904,912 **** l = snprintf(repo, sizeof(repo), "%s/%s", cvs_repo_base, dir); if (l == -1 || l >= (int)sizeof(repo)) ! return (-1); } else { ! strlcpy(repo, dir, sizeof(repo)); } if (cvs_mkadmin(dir, root->cr_str, repo, NULL, NULL, 0) < 0) --- 877,887 ---- l = snprintf(repo, sizeof(repo), "%s/%s", cvs_repo_base, dir); if (l == -1 || l >= (int)sizeof(repo)) ! fatal("resp_check_dir: path overflow"); } else { ! len = strlcpy(repo, dir, sizeof(repo)); ! if (len >= sizeof(repo)) ! fatal("resp_check_dir: path truncation"); } if (cvs_mkadmin(dir, root->cr_str, repo, NULL, NULL, 0) < 0) *************** *** 921,931 **** return (-1); len = strlcpy(cvs_resp_lastdir, dir, sizeof(cvs_resp_lastdir)); ! if (len >= sizeof(cvs_resp_lastdir)) { ! errno = ENAMETOOLONG; ! cvs_log(LP_ERRNO, "%s", cvs_resp_lastdir); ! return (-1); ! } } else { /* make sure the old one is still open */ if (cvs_resp_lastent == NULL) { --- 896,903 ---- return (-1); len = strlcpy(cvs_resp_lastdir, dir, sizeof(cvs_resp_lastdir)); ! if (len >= sizeof(cvs_resp_lastdir)) ! fatal("resp_check_dir: path truncation"); } else { /* make sure the old one is still open */ if (cvs_resp_lastent == NULL) {