version 1.68, 2006/01/02 08:11:56 |
version 1.69, 2006/01/25 08:15:05 |
|
|
static int |
static int |
cvs_resp_statdir(struct cvsroot *root, int type, char *line) |
cvs_resp_statdir(struct cvsroot *root, int type, char *line) |
{ |
{ |
int fd, len; |
int fd; |
char rpath[MAXPATHLEN], statpath[MAXPATHLEN]; |
char rpath[MAXPATHLEN], statpath[MAXPATHLEN]; |
|
|
/* remote directory line */ |
/* remote directory line */ |
|
|
*/ |
*/ |
if (cvs_resp_createdir(line) < 0) |
if (cvs_resp_createdir(line) < 0) |
return (-1); |
return (-1); |
|
if (strlcpy(statpath, line, sizeof(statpath)) >= sizeof(statpath) || |
len = snprintf(statpath, sizeof(statpath), "%s/%s", line, |
strlcat(statpath, "/", sizeof(statpath)) >= sizeof(statpath) || |
CVS_PATH_STATICENTRIES); |
strlcat(statpath, CVS_PATH_STATICENTRIES, |
if (len == -1 || len >= (int)sizeof(statpath)) { |
sizeof(statpath)) >= sizeof(statpath)) |
cvs_log(LP_ERR, |
cvs_log(LP_ERR, "Entries.static path truncation"); |
"path overflow for Entries.static specification"); |
|
return (-1); |
return (-1); |
} |
|
|
|
if (cvs_noexec == 0) { |
if (cvs_noexec == 0) { |
if ((type == CVS_RESP_CLRSTATDIR) && |
if ((type == CVS_RESP_CLRSTATDIR) && |
|
|
static int |
static int |
cvs_resp_copyfile(struct cvsroot *root, int type, char *line) |
cvs_resp_copyfile(struct cvsroot *root, int type, char *line) |
{ |
{ |
int len; |
|
char path[MAXPATHLEN], newpath[MAXPATHLEN]; |
char path[MAXPATHLEN], newpath[MAXPATHLEN]; |
char newname[MAXNAMLEN], *file; |
char newname[MAXNAMLEN], *file; |
|
|
|
|
if ((file = basename(path)) == NULL) |
if ((file = basename(path)) == NULL) |
fatal("no base file name in Copy-file path"); |
fatal("no base file name in Copy-file path"); |
|
|
len = snprintf(path, sizeof(path), "%s%s", line, file); |
if (strlcpy(path, line, sizeof(path)) >= sizeof(path) || |
if (len == -1 || len >= (int)sizeof(path)) |
strlcat(path, file, sizeof(path)) >= sizeof(path)) |
fatal("source path overflow in Copy-file response"); |
fatal("source path overflow in Copy-file response"); |
|
|
len = snprintf(newpath, sizeof(newpath), "%s%s", line, newname); |
if (strlcpy(newpath, line, sizeof(newpath)) >= sizeof(newpath) || |
if (len == -1 || len >= (int)sizeof(path)) |
strlcat(newpath, newname, sizeof(newpath)) >= sizeof(newpath)) |
fatal("destination path overflow in Copy-file response"); |
fatal("destination path overflow in Copy-file response"); |
|
|
if (rename(path, newpath) == -1) { |
if (rename(path, newpath) == -1) { |
fatal("failed to rename %s to %s: %s", |
fatal("cvs_resp_copyfile: rename: `%s'->`%s': %s", |
path, newpath, strerror(errno)); |
path, newpath, strerror(errno)); |
} |
} |
|
|
|
|
struct cvs_ent *ent; |
struct cvs_ent *ent; |
struct timeval tv[2]; |
struct timeval tv[2]; |
|
|
|
ret = 0; |
|
|
STRIP_SLASH(line); |
STRIP_SLASH(line); |
|
|
/* read the remote path of the file */ |
/* read the remote path of the file */ |
|
|
if ((ent = cvs_ent_parse(path)) == NULL) |
if ((ent = cvs_ent_parse(path)) == NULL) |
return (-1); |
return (-1); |
|
|
ret = snprintf(path, sizeof(path), "%s/%s", line, ent->ce_name); |
if (strlcpy(path, line, sizeof(path)) >= sizeof(path) || |
if (ret == -1 || ret >= (int)sizeof(path)) |
strlcat(path, "/", sizeof(path)) >= sizeof(path) || |
|
strlcat(path, ent->ce_name, sizeof(path)) >= sizeof(path)) |
fatal("Entries path overflow in response"); |
fatal("Entries path overflow in response"); |
|
|
ret = 0; |
|
|
|
/* |
/* |
* Please be sure the directory does exist. |
* Please be sure the directory does exist. |
*/ |
*/ |
|
|
static int |
static int |
cvs_resp_removed(struct cvsroot *root, int type, char *line) |
cvs_resp_removed(struct cvsroot *root, int type, char *line) |
{ |
{ |
int l; |
|
char buf[MAXPATHLEN], base[MAXPATHLEN]; |
char buf[MAXPATHLEN], base[MAXPATHLEN]; |
char fpath[MAXPATHLEN], *file; |
char fpath[MAXPATHLEN], *file; |
|
|
cvs_getln(root, buf, sizeof(buf)); |
cvs_getln(root, buf, sizeof(buf)); |
|
|
cvs_splitpath(buf, base, sizeof(base), &file); |
cvs_splitpath(buf, base, sizeof(base), &file); |
l = snprintf(fpath, sizeof(fpath), "%s/%s", line, file); |
|
if (l == -1 || l >= (int)sizeof(fpath)) |
if (strlcpy(fpath, line, sizeof(fpath)) >= sizeof(fpath) || |
|
strlcat(fpath, "/", sizeof(fpath)) >= sizeof(fpath) || |
|
strlcat(fpath, file, sizeof(fpath)) >= sizeof(fpath)) |
fatal("cvs_resp_removed: overflow in path"); |
fatal("cvs_resp_removed: overflow in path"); |
|
|
if (resp_check_dir(root, line) < 0) |
if (resp_check_dir(root, line) < 0) |
|
|
static int |
static int |
cvs_resp_rcsdiff(struct cvsroot *root, int type, char *line) |
cvs_resp_rcsdiff(struct cvsroot *root, int type, char *line) |
{ |
{ |
int len; |
|
char file[MAXPATHLEN]; |
char file[MAXPATHLEN]; |
char buf[CVS_ENT_MAXLINELEN], cksum_buf[CVS_CKSUM_LEN]; |
char buf[CVS_ENT_MAXLINELEN], cksum_buf[CVS_CKSUM_LEN]; |
char *fname, *orig, *patch; |
char *fname, *orig, *patch; |
|
|
fname = strrchr(buf, '/'); |
fname = strrchr(buf, '/'); |
if (fname == NULL) |
if (fname == NULL) |
fname = buf; |
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"); |
|
|
|
|
if (strlcpy(file, line, sizeof(file)) >= sizeof(file) || |
|
strlcat(file, fname, sizeof(file)) >= sizeof(file)) |
|
fatal("cvs_resp_rcsdiff: path truncation"); |
|
|
/* get updated entry fields */ |
/* get updated entry fields */ |
cvs_getln(root, buf, sizeof(buf)); |
cvs_getln(root, buf, sizeof(buf)); |
|
|
|
|
static int |
static int |
resp_check_dir(struct cvsroot *root, const char *dir) |
resp_check_dir(struct cvsroot *root, const char *dir) |
{ |
{ |
int l; |
|
size_t len; |
|
char cvspath[MAXPATHLEN], repo[MAXPATHLEN]; |
char cvspath[MAXPATHLEN], repo[MAXPATHLEN]; |
struct stat st; |
struct stat st; |
|
|
/* |
/* |
* Make sure the CVS directory exists. |
* Make sure the CVS directory exists. |
*/ |
*/ |
l = snprintf(cvspath, sizeof(cvspath), "%s/%s", dir, CVS_PATH_CVSDIR); |
if (strlcpy(cvspath, dir, sizeof(cvspath)) >= sizeof(cvspath) || |
if (l == -1 || l >= (int)sizeof(cvspath)) |
strlcat(cvspath, "/", sizeof(cvspath)) >= sizeof(cvspath) || |
|
strlcat(cvspath, CVS_PATH_CVSDIR, |
|
sizeof(cvspath)) >= sizeof(cvspath)) |
fatal("resp_check_dir: path overflow"); |
fatal("resp_check_dir: path overflow"); |
|
|
if (stat(cvspath, &st) == -1) { |
if (stat(cvspath, &st) == -1) { |
if (errno != ENOENT) |
if (errno != ENOENT) |
return (-1); |
return (-1); |
if (cvs_repo_base != NULL) { |
if (cvs_repo_base != NULL) { |
l = snprintf(repo, sizeof(repo), "%s/%s", cvs_repo_base, |
if (strlcpy(repo, cvs_repo_base, |
dir); |
sizeof(repo)) >= sizeof(repo) || |
if (l == -1 || l >= (int)sizeof(repo)) |
strlcat(repo, "/", sizeof(repo)) >= sizeof(repo) || |
|
strlcat(repo, dir, sizeof(repo)) >= sizeof(repo)) |
fatal("resp_check_dir: path overflow"); |
fatal("resp_check_dir: path overflow"); |
} else { |
} else { |
len = strlcpy(repo, dir, sizeof(repo)); |
if (strlcpy(repo, dir, sizeof(repo)) >= sizeof(repo)) |
if (len >= sizeof(repo)) |
|
fatal("resp_check_dir: path truncation"); |
fatal("resp_check_dir: path truncation"); |
} |
} |
|
|
|
|
if (cvs_resp_lastent == NULL) |
if (cvs_resp_lastent == NULL) |
return (-1); |
return (-1); |
|
|
len = strlcpy(cvs_resp_lastdir, dir, sizeof(cvs_resp_lastdir)); |
if (strlcpy(cvs_resp_lastdir, dir, |
if (len >= sizeof(cvs_resp_lastdir)) |
sizeof(cvs_resp_lastdir)) >= sizeof(cvs_resp_lastdir)) |
fatal("resp_check_dir: path truncation"); |
fatal("resp_check_dir: path truncation"); |
} else { |
} else { |
/* make sure the old one is still open */ |
/* make sure the old one is still open */ |