|
|
#ifdef KERBEROS | #ifdef KERBEROS |
case 'k': | case 'k': |
dest_realm = dst_realm_buf; | dest_realm = dst_realm_buf; |
(void)strncpy(dst_realm_buf, optarg, REALM_SZ); |
memset(dst_realm_buf, 0, REALM_SZ); |
|
(void)strncpy(dst_realm_buf, optarg, REALM_SZ-1); |
break; | break; |
#ifdef CRYPT | #ifdef CRYPT |
case 'x': | case 'x': |
|
|
| |
if (fflag) { /* Follow "protocol", send data. */ | if (fflag) { /* Follow "protocol", send data. */ |
(void)response(); | (void)response(); |
(void)setuid(userid); |
if(setuid(userid) != 0) |
|
errx(1, "can't change to uid %d", (int)userid); |
source(argc, argv); | source(argc, argv); |
exit(errs); | exit(errs); |
} | } |
| |
if (tflag) { /* Receive data. */ | if (tflag) { /* Receive data. */ |
(void)setuid(userid); |
if(setuid(userid) != 0) |
|
errx(1, "can't change to uid %d", (int)userid); |
sink(argc, argv); | sink(argc, argv); |
exit(errs); | exit(errs); |
} | } |
|
|
| |
for (size = 0; isdigit(*cp);) | for (size = 0; isdigit(*cp);) |
size = size * 10 + (*cp++ - '0'); | size = size * 10 + (*cp++ - '0'); |
|
if(size < 0) // integer overflow, more can happen in the loop but lets avoid testing for the sake of performance |
|
SCREWUP("size becomes too big and swapped"); |
|
|
if (*cp++ != ' ') | if (*cp++ != ' ') |
SCREWUP("size not delimited"); | SCREWUP("size not delimited"); |
if (targisdir) { | if (targisdir) { |
|
|
static int cursize; | static int cursize; |
size_t need; | size_t need; |
| |
need = strlen(targ) + strlen(cp) + 250; |
need = strlen(targ) + strlen(cp) + 250; // b/c this might overflow (very unlikely) we use sNprintf() later |
if (need > cursize) { | if (need > cursize) { |
if (!(namebuf = malloc(need))) |
if (!(namebuf = malloc(need))) // will not set a limit here |
run_err("%s", strerror(errno)); | run_err("%s", strerror(errno)); |
} | } |
(void)sprintf(namebuf, "%s%s%s", targ, |
(void)snprintf(namebuf, need, "%s%s%s", targ, |
*targ ? "/" : "", cp); | *targ ? "/" : "", cp); |
np = namebuf; | np = namebuf; |
} else | } else |
|
|
{ | { |
char ch, *cp, resp, rbuf[BUFSIZ]; | char ch, *cp, resp, rbuf[BUFSIZ]; |
| |
|
memset(rbuf, 0, BUFSIZ); |
|
|
if (read(rem, &resp, sizeof(resp)) != sizeof(resp)) | if (read(rem, &resp, sizeof(resp)) != sizeof(resp)) |
lostconn(0); | lostconn(0); |
| |
|
|
if (read(rem, &ch, sizeof(ch)) != sizeof(ch)) | if (read(rem, &ch, sizeof(ch)) != sizeof(ch)) |
lostconn(0); | lostconn(0); |
*cp++ = ch; | *cp++ = ch; |
} while (cp < &rbuf[BUFSIZ] && ch != '\n'); |
} while (cp < &rbuf[BUFSIZ-1] && ch != '\n'); |
| |
if (!iamremote) | if (!iamremote) |
(void)write(STDERR_FILENO, rbuf, cp - rbuf); | (void)write(STDERR_FILENO, rbuf, cp - rbuf); |