version 1.24, 2005/10/14 13:46:36 |
version 1.25, 2005/12/20 16:55:21 |
|
|
size_t len; |
size_t len; |
char reqbuf[512]; |
char reqbuf[512]; |
|
|
if (argc != 1) { |
if (argc != 1) |
return (CVS_EX_USAGE); |
return (CVS_EX_USAGE); |
} |
|
|
|
/* make sure standard in and standard out are line-buffered */ |
/* make sure standard in and standard out are line-buffered */ |
(void)setvbuf(stdin, NULL, _IOLBF, (size_t)0); |
(void)setvbuf(stdin, NULL, _IOLBF, (size_t)0); |
|
|
"%s/cvs-serv%d", cvs_tmpdir, getpid()); |
"%s/cvs-serv%d", cvs_tmpdir, getpid()); |
if (l == -1 || l >= (int)sizeof(cvs_server_tmpdir)) { |
if (l == -1 || l >= (int)sizeof(cvs_server_tmpdir)) { |
errno = ENAMETOOLONG; |
errno = ENAMETOOLONG; |
cvs_log(LP_ERRNO, "%s", cvs_server_tmpdir); |
fatal("cvs_server: tmpdir path too long: `%s'", |
return (CVS_EX_DATA); |
|
} |
|
|
|
if (mkdir(cvs_server_tmpdir, 0700) == -1) { |
|
cvs_log(LP_ERRNO, "failed to create temporary directory '%s'", |
|
cvs_server_tmpdir); |
cvs_server_tmpdir); |
return (CVS_EX_FILE); |
|
} |
} |
|
|
|
if (mkdir(cvs_server_tmpdir, 0700) == -1) |
|
fatal("cvs_server: mkdir: `%s': %s", |
|
cvs_server_tmpdir, strerror(errno)); |
|
|
if (cvs_chdir(cvs_server_tmpdir) == -1) { |
if (cvs_chdir(cvs_server_tmpdir) == -1) { |
cvs_rmdir(cvs_server_tmpdir); |
(void)cvs_rmdir(cvs_server_tmpdir); |
return (CVS_EX_FILE); |
fatal("cvs_server: cvs_chdir failed"); |
} |
} |
|
|
for (;;) { |
for (;;) { |
|
|
if (feof(stdin)) |
if (feof(stdin)) |
break; |
break; |
else if (ferror(stdin)) { |
else if (ferror(stdin)) { |
cvs_rmdir(cvs_server_tmpdir); |
(void)cvs_rmdir(cvs_server_tmpdir); |
return (CVS_EX_DATA); |
fatal("cvs_server: fgets failed"); |
} |
} |
} |
} |
|
|
|
|
if (len == 0) |
if (len == 0) |
continue; |
continue; |
else if (reqbuf[len - 1] != '\n') { |
else if (reqbuf[len - 1] != '\n') { |
cvs_log(LP_ERR, "truncated request"); |
(void)cvs_rmdir(cvs_server_tmpdir); |
cvs_rmdir(cvs_server_tmpdir); |
fatal("cvs_server: truncated request"); |
return (CVS_EX_PROTO); |
|
} |
} |
reqbuf[--len] = '\0'; |
reqbuf[--len] = '\0'; |
|
|