Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Theo Markettos's unsigned-vs-signed-char pedantry patch. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
d58f7637c15dfd5d81e4c8d0e4e068e0 |
| User & Date: | simon 2004-01-21 13:45:44.000 |
Context
|
2004-01-21
| ||
| 13:56 | Darryl L. Miles's patch to support an optional port number argument on the PSFTP `open' command; it was arguably a bug that this command couldn't do such an obvious thing that could be done from the main command line. Also had to fix a NULL-dereference in do_sftp_cleanup in the process. check-in: 84e5eca94f user: simon tags: trunk | |
| 13:45 | Theo Markettos's unsigned-vs-signed-char pedantry patch. check-in: d58f7637c1 user: simon tags: trunk | |
| 13:41 | Two small memory leaks, also noticed by Martin Prikryl. check-in: 086da3a301 user: simon tags: trunk | |
Changes
Changes to portfwd.c.
| ︙ | ︙ | |||
251 252 253 254 255 256 257 |
alen = 16;
if (atype == 3) /* domain name has leading length */
alen = 1 + (unsigned char)pr->hostname[4];
if (pr->port < 6 + alen) continue;
if (pr->hostname[1] != 1 || pr->hostname[2] != 0) {
/* Not CONNECT or reserved field nonzero - error */
reply[1] = 1; /* generic failure */
| | | | | | | | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
alen = 16;
if (atype == 3) /* domain name has leading length */
alen = 1 + (unsigned char)pr->hostname[4];
if (pr->port < 6 + alen) continue;
if (pr->hostname[1] != 1 || pr->hostname[2] != 0) {
/* Not CONNECT or reserved field nonzero - error */
reply[1] = 1; /* generic failure */
sk_write(pr->s, (char *) reply, lenof(reply));
pfd_close(pr->s);
return 1;
}
/*
* Now we have a viable connect request. Switch
* on atype.
*/
pr->port = GET_16BIT_MSB_FIRST(pr->hostname+4+alen);
if (atype == 1) {
/* REP=0 (success) already */
sk_write(pr->s, (char *) reply, lenof(reply));
sprintf(pr->hostname, "%d.%d.%d.%d",
(unsigned char)pr->hostname[4],
(unsigned char)pr->hostname[5],
(unsigned char)pr->hostname[6],
(unsigned char)pr->hostname[7]);
goto connect;
} else if (atype == 3) {
/* REP=0 (success) already */
sk_write(pr->s, (char *) reply, lenof(reply));
memmove(pr->hostname, pr->hostname + 5, alen-1);
pr->hostname[alen-1] = '\0';
goto connect;
} else {
/*
* Unknown address type. (FIXME: support IPv6!)
*/
reply[1] = 8; /* atype not supported */
sk_write(pr->s, (char *) reply, lenof(reply));
pfd_close(pr->s);
return 1;
}
}
}
/*
* If we get here without either having done `continue'
* or `goto connect', it must be because there is no
* sensible interpretation of what's in our buffer. So
* close the connection rudely.
*/
pfd_close(pr->s);
|
| ︙ | ︙ |
Changes to psftp.c.
| ︙ | ︙ | |||
1737 1738 1739 1740 1741 1742 1743 |
return 0; /* doom */
}
return 1;
}
int sftp_senddata(char *buf, int len)
{
| | | 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 |
return 0; /* doom */
}
return 1;
}
int sftp_senddata(char *buf, int len)
{
back->send(backhandle, buf, len);
return 1;
}
/*
* Short description of parameters.
*/
static void usage(void)
|
| ︙ | ︙ |
Changes to scp.c.
| ︙ | ︙ | |||
286 287 288 289 290 291 292 |
tell_str(stderr, str2);
sfree(str2);
errs++;
if (back != NULL && back->socket(backhandle) != NULL) {
char ch;
back->special(backhandle, TS_EOF);
| | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
tell_str(stderr, str2);
sfree(str2);
errs++;
if (back != NULL && back->socket(backhandle) != NULL) {
char ch;
back->special(backhandle, TS_EOF);
ssh_scp_recv((unsigned char *) &ch, 1);
}
if (gui_mode)
gui_send_errcount(list, errs);
cleanup_exit(1);
}
|
| ︙ | ︙ | |||
451 452 453 454 455 456 457 |
eta = (unsigned long) ((size - done) / ratebs);
sprintf(etastr, "%02ld:%02ld:%02ld",
eta / 3600, (eta % 3600) / 60, eta % 60);
pct = (int) (100 * (done * 1.0 / size));
if (gui_mode) {
| | | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
eta = (unsigned long) ((size - done) / ratebs);
sprintf(etastr, "%02ld:%02ld:%02ld",
eta / 3600, (eta % 3600) / 60, eta % 60);
pct = (int) (100 * (done * 1.0 / size));
if (gui_mode) {
gui_update_stats(name, size, pct, elap, done, eta,
(unsigned long) ratebs);
} else {
len = printf("\r%-25.25s | %10ld kB | %5.1f kB/s | ETA: %8s | %3d%%",
name, done / 1024, ratebs / 1024.0, etastr, pct);
if (len < prev_stats_len)
printf("%*s", prev_stats_len - len, "");
prev_stats_len = len;
|
| ︙ | ︙ | |||
527 528 529 530 531 532 533 |
* Return 0 if ok, -1 if error.
*/
static int response(void)
{
char ch, resp, rbuf[2048];
int p;
| | | | | | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
* Return 0 if ok, -1 if error.
*/
static int response(void)
{
char ch, resp, rbuf[2048];
int p;
if (ssh_scp_recv((unsigned char *) &resp, 1) <= 0)
bump("Lost connection");
p = 0;
switch (resp) {
case 0: /* ok */
return (0);
default:
rbuf[p++] = resp;
/* fallthrough */
case 1: /* error */
case 2: /* fatal error */
do {
if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0)
bump("Protocol error: Lost connection");
rbuf[p++] = ch;
} while (p < sizeof(rbuf) && ch != '\n');
rbuf[p - 1] = '\0';
if (resp == 1)
tell_user(stderr, "%s\n", rbuf);
else
bump("%s", rbuf);
errs++;
return (-1);
}
}
int sftp_recvdata(char *buf, int len)
{
return ssh_scp_recv((unsigned char *) buf, len);
}
int sftp_senddata(char *buf, int len)
{
back->send(backhandle, buf, len);
return 1;
}
/* ----------------------------------------------------------------------
* sftp-based replacement for the hacky `pscp -ls'.
*/
static int sftp_ls_compare(const void *av, const void *bv)
|
| ︙ | ︙ | |||
1316 1317 1318 1319 1320 1321 1322 |
char ch;
act->settime = 0;
act->buf = NULL;
bufsize = 0;
while (!done) {
| | | | 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 |
char ch;
act->settime = 0;
act->buf = NULL;
bufsize = 0;
while (!done) {
if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0)
return 1;
if (ch == '\n')
bump("Protocol error: Unexpected newline");
i = 0;
action = ch;
do {
if (ssh_scp_recv((unsigned char *) &ch, 1) <= 0)
bump("Lost connection");
if (i >= bufsize) {
bufsize = i + 128;
act->buf = sresize(act->buf, bufsize, char);
}
act->buf[i++] = ch;
} while (ch != '\n');
|
| ︙ | ︙ | |||
1438 1439 1440 1441 1442 1443 1444 |
} else
actuallen = 0;
scp_sftp_fileoffset = uint64_add32(scp_sftp_fileoffset, actuallen);
return actuallen;
} else {
| | | 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 |
} else
actuallen = 0;
scp_sftp_fileoffset = uint64_add32(scp_sftp_fileoffset, actuallen);
return actuallen;
} else {
return ssh_scp_recv((unsigned char *) data, len);
}
}
int scp_finish_filerecv(void)
{
if (using_sftp) {
struct sftp_packet *pktin;
|
| ︙ | ︙ | |||
2030 2031 2032 2033 2034 2035 2036 |
do_cmd(host, user, cmd);
sfree(cmd);
if (using_sftp) {
scp_sftp_listdir(src);
} else {
| | | 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 |
do_cmd(host, user, cmd);
sfree(cmd);
if (using_sftp) {
scp_sftp_listdir(src);
} else {
while (ssh_scp_recv((unsigned char *) &c, 1) > 0)
tell_char(stdout, c);
}
}
/*
* Short description of parameters.
*/
|
| ︙ | ︙ | |||
2167 2168 2169 2170 2171 2172 2173 |
else
tolocal(argc, argv);
}
if (back != NULL && back->socket(backhandle) != NULL) {
char ch;
back->special(backhandle, TS_EOF);
| | | 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 |
else
tolocal(argc, argv);
}
if (back != NULL && back->socket(backhandle) != NULL) {
char ch;
back->special(backhandle, TS_EOF);
ssh_scp_recv((unsigned char *) &ch, 1);
}
random_save_seed();
if (gui_mode)
gui_send_errcount(list, errs);
cmdline_cleanup();
|
| ︙ | ︙ |
Changes to unix/uxnet.c.
| ︙ | ︙ | |||
867 868 869 870 871 872 873 | */ struct sockaddr_in isa; int addrlen = sizeof(struct sockaddr_in); int t; /* socket of connection */ memset(&isa, 0, sizeof(struct sockaddr_in)); err = 0; | | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
*/
struct sockaddr_in isa;
int addrlen = sizeof(struct sockaddr_in);
int t; /* socket of connection */
memset(&isa, 0, sizeof(struct sockaddr_in));
err = 0;
t = accept(s->s,(struct sockaddr *)&isa,(socklen_t *) &addrlen);
if (t < 0) {
break;
}
if (s->localhost_only && !ipv4_is_loopback(isa.sin_addr)) {
close(t); /* someone let nonlocal through?! */
} else if (plug_accepting(s->plug, t)) {
|
| ︙ | ︙ |