diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-02-09 02:58:04 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-02-09 02:58:04 +0000 |
commit | 288cc3970cd22cbbb6a3b9ba74cd25442c938ee5 (patch) | |
tree | 106c3c4011b2b51db30f77c683d754959227dc8c | |
parent | 1e7d30611bc8d7c2383fc59133996363f84a5911 (diff) |
- djm@cvs.openbsd.org 2001/02/06 23:30:28
[sftp-client.c]
replace arc4random with counter for request ids; ok markus@
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sftp-client.c | 37 |
2 files changed, 25 insertions, 18 deletions
@@ -44,6 +44,10 @@ | |||
44 | [ssh.c] | 44 | [ssh.c] |
45 | reorder -{1,2,4,6} options. ok markus@ | 45 | reorder -{1,2,4,6} options. ok markus@ |
46 | - (bal) Missing 'const' in readpass.h | 46 | - (bal) Missing 'const' in readpass.h |
47 | - (bal) OpenBSD Sync (so at least the thing compiles for 2.3.2 =) | ||
48 | - djm@cvs.openbsd.org 2001/02/06 23:30:28 | ||
49 | [sftp-client.c] | ||
50 | replace arc4random with counter for request ids; ok markus@ | ||
47 | 51 | ||
48 | 20010208 | 52 | 20010208 |
49 | - (djm) Don't delete external askpass program in make uninstall target. | 53 | - (djm) Don't delete external askpass program in make uninstall target. |
@@ -3697,4 +3701,4 @@ | |||
3697 | - Wrote replacements for strlcpy and mkdtemp | 3701 | - Wrote replacements for strlcpy and mkdtemp |
3698 | - Released 1.0pre1 | 3702 | - Released 1.0pre1 |
3699 | 3703 | ||
3700 | $Id: ChangeLog,v 1.707 2001/02/09 02:36:43 mouring Exp $ | 3704 | $Id: ChangeLog,v 1.708 2001/02/09 02:58:04 mouring Exp $ |
diff --git a/sftp-client.c b/sftp-client.c index e42823841..e8b9007fe 100644 --- a/sftp-client.c +++ b/sftp-client.c | |||
@@ -29,7 +29,7 @@ | |||
29 | /* XXX: copy between two remote sites */ | 29 | /* XXX: copy between two remote sites */ |
30 | 30 | ||
31 | #include "includes.h" | 31 | #include "includes.h" |
32 | RCSID("$OpenBSD: sftp-client.c,v 1.3 2001/02/04 15:32:25 stevesk Exp $"); | 32 | RCSID("$OpenBSD: sftp-client.c,v 1.4 2001/02/06 23:30:28 djm Exp $"); |
33 | 33 | ||
34 | #include "ssh.h" | 34 | #include "ssh.h" |
35 | #include "buffer.h" | 35 | #include "buffer.h" |
@@ -48,6 +48,9 @@ RCSID("$OpenBSD: sftp-client.c,v 1.3 2001/02/04 15:32:25 stevesk Exp $"); | |||
48 | /* XXX: what should this be? */ | 48 | /* XXX: what should this be? */ |
49 | #define COPY_SIZE 8192 | 49 | #define COPY_SIZE 8192 |
50 | 50 | ||
51 | /* Message ID */ | ||
52 | static u_int msg_id = 1; | ||
53 | |||
51 | void | 54 | void |
52 | send_msg(int fd, Buffer *m) | 55 | send_msg(int fd, Buffer *m) |
53 | { | 56 | { |
@@ -255,7 +258,7 @@ do_close(int fd_in, int fd_out, char *handle, u_int handle_len) | |||
255 | 258 | ||
256 | buffer_init(&msg); | 259 | buffer_init(&msg); |
257 | 260 | ||
258 | id = arc4random(); | 261 | id = msg_id++; |
259 | buffer_put_char(&msg, SSH2_FXP_CLOSE); | 262 | buffer_put_char(&msg, SSH2_FXP_CLOSE); |
260 | buffer_put_int(&msg, id); | 263 | buffer_put_int(&msg, id); |
261 | buffer_put_string(&msg, handle, handle_len); | 264 | buffer_put_string(&msg, handle, handle_len); |
@@ -278,7 +281,7 @@ do_ls(int fd_in, int fd_out, char *path) | |||
278 | u_int type, id, handle_len, i, expected_id; | 281 | u_int type, id, handle_len, i, expected_id; |
279 | char *handle; | 282 | char *handle; |
280 | 283 | ||
281 | id = arc4random(); | 284 | id = msg_id++; |
282 | 285 | ||
283 | buffer_init(&msg); | 286 | buffer_init(&msg); |
284 | buffer_put_char(&msg, SSH2_FXP_OPENDIR); | 287 | buffer_put_char(&msg, SSH2_FXP_OPENDIR); |
@@ -295,7 +298,7 @@ do_ls(int fd_in, int fd_out, char *path) | |||
295 | for(;;) { | 298 | for(;;) { |
296 | int count; | 299 | int count; |
297 | 300 | ||
298 | expected_id = ++id; | 301 | id = expected_id = msg_id++; |
299 | 302 | ||
300 | debug3("Sending SSH2_FXP_READDIR I:%d", id); | 303 | debug3("Sending SSH2_FXP_READDIR I:%d", id); |
301 | 304 | ||
@@ -365,7 +368,7 @@ do_rm(int fd_in, int fd_out, char *path) | |||
365 | 368 | ||
366 | debug2("Sending SSH2_FXP_REMOVE \"%s\"", path); | 369 | debug2("Sending SSH2_FXP_REMOVE \"%s\"", path); |
367 | 370 | ||
368 | id = arc4random(); | 371 | id = msg_id++; |
369 | send_string_request(fd_out, id, SSH2_FXP_REMOVE, path, strlen(path)); | 372 | send_string_request(fd_out, id, SSH2_FXP_REMOVE, path, strlen(path)); |
370 | status = get_status(fd_in, id); | 373 | status = get_status(fd_in, id); |
371 | if (status != SSH2_FX_OK) | 374 | if (status != SSH2_FX_OK) |
@@ -378,7 +381,7 @@ do_mkdir(int fd_in, int fd_out, char *path, Attrib *a) | |||
378 | { | 381 | { |
379 | u_int status, id; | 382 | u_int status, id; |
380 | 383 | ||
381 | id = arc4random(); | 384 | id = msg_id++; |
382 | send_string_attrs_request(fd_out, id, SSH2_FXP_MKDIR, path, | 385 | send_string_attrs_request(fd_out, id, SSH2_FXP_MKDIR, path, |
383 | strlen(path), a); | 386 | strlen(path), a); |
384 | 387 | ||
@@ -394,7 +397,7 @@ do_rmdir(int fd_in, int fd_out, char *path) | |||
394 | { | 397 | { |
395 | u_int status, id; | 398 | u_int status, id; |
396 | 399 | ||
397 | id = arc4random(); | 400 | id = msg_id++; |
398 | send_string_request(fd_out, id, SSH2_FXP_RMDIR, path, strlen(path)); | 401 | send_string_request(fd_out, id, SSH2_FXP_RMDIR, path, strlen(path)); |
399 | 402 | ||
400 | status = get_status(fd_in, id); | 403 | status = get_status(fd_in, id); |
@@ -409,7 +412,7 @@ do_stat(int fd_in, int fd_out, char *path) | |||
409 | { | 412 | { |
410 | u_int id; | 413 | u_int id; |
411 | 414 | ||
412 | id = arc4random(); | 415 | id = msg_id++; |
413 | send_string_request(fd_out, id, SSH2_FXP_STAT, path, strlen(path)); | 416 | send_string_request(fd_out, id, SSH2_FXP_STAT, path, strlen(path)); |
414 | return(get_decode_stat(fd_in, id)); | 417 | return(get_decode_stat(fd_in, id)); |
415 | } | 418 | } |
@@ -419,7 +422,7 @@ do_lstat(int fd_in, int fd_out, char *path) | |||
419 | { | 422 | { |
420 | u_int id; | 423 | u_int id; |
421 | 424 | ||
422 | id = arc4random(); | 425 | id = msg_id++; |
423 | send_string_request(fd_out, id, SSH2_FXP_LSTAT, path, strlen(path)); | 426 | send_string_request(fd_out, id, SSH2_FXP_LSTAT, path, strlen(path)); |
424 | return(get_decode_stat(fd_in, id)); | 427 | return(get_decode_stat(fd_in, id)); |
425 | } | 428 | } |
@@ -430,7 +433,7 @@ do_fstat(int fd_in, int fd_out, char *handle, | |||
430 | { | 433 | { |
431 | u_int id; | 434 | u_int id; |
432 | 435 | ||
433 | id = arc4random(); | 436 | id = msg_id++; |
434 | send_string_request(fd_out, id, SSH2_FXP_FSTAT, handle, handle_len); | 437 | send_string_request(fd_out, id, SSH2_FXP_FSTAT, handle, handle_len); |
435 | return(get_decode_stat(fd_in, id)); | 438 | return(get_decode_stat(fd_in, id)); |
436 | } | 439 | } |
@@ -440,7 +443,7 @@ do_setstat(int fd_in, int fd_out, char *path, Attrib *a) | |||
440 | { | 443 | { |
441 | u_int status, id; | 444 | u_int status, id; |
442 | 445 | ||
443 | id = arc4random(); | 446 | id = msg_id++; |
444 | send_string_attrs_request(fd_out, id, SSH2_FXP_SETSTAT, path, | 447 | send_string_attrs_request(fd_out, id, SSH2_FXP_SETSTAT, path, |
445 | strlen(path), a); | 448 | strlen(path), a); |
446 | 449 | ||
@@ -458,7 +461,7 @@ do_fsetstat(int fd_in, int fd_out, char *handle, u_int handle_len, | |||
458 | { | 461 | { |
459 | u_int status, id; | 462 | u_int status, id; |
460 | 463 | ||
461 | id = arc4random(); | 464 | id = msg_id++; |
462 | send_string_attrs_request(fd_out, id, SSH2_FXP_FSETSTAT, handle, | 465 | send_string_attrs_request(fd_out, id, SSH2_FXP_FSETSTAT, handle, |
463 | handle_len, a); | 466 | handle_len, a); |
464 | 467 | ||
@@ -477,7 +480,7 @@ do_realpath(int fd_in, int fd_out, char *path) | |||
477 | char *filename, *longname; | 480 | char *filename, *longname; |
478 | Attrib *a; | 481 | Attrib *a; |
479 | 482 | ||
480 | expected_id = id = arc4random(); | 483 | expected_id = id = msg_id++; |
481 | send_string_request(fd_out, id, SSH2_FXP_REALPATH, path, | 484 | send_string_request(fd_out, id, SSH2_FXP_REALPATH, path, |
482 | strlen(path)); | 485 | strlen(path)); |
483 | 486 | ||
@@ -525,7 +528,7 @@ do_rename(int fd_in, int fd_out, char *oldpath, char *newpath) | |||
525 | buffer_init(&msg); | 528 | buffer_init(&msg); |
526 | 529 | ||
527 | /* Send rename request */ | 530 | /* Send rename request */ |
528 | id = arc4random(); | 531 | id = msg_id++; |
529 | buffer_put_char(&msg, SSH2_FXP_RENAME); | 532 | buffer_put_char(&msg, SSH2_FXP_RENAME); |
530 | buffer_put_int(&msg, id); | 533 | buffer_put_int(&msg, id); |
531 | buffer_put_cstring(&msg, oldpath); | 534 | buffer_put_cstring(&msg, oldpath); |
@@ -588,7 +591,7 @@ do_download(int fd_in, int fd_out, char *remote_path, char *local_path, | |||
588 | buffer_init(&msg); | 591 | buffer_init(&msg); |
589 | 592 | ||
590 | /* Send open request */ | 593 | /* Send open request */ |
591 | id = arc4random(); | 594 | id = msg_id++; |
592 | buffer_put_char(&msg, SSH2_FXP_OPEN); | 595 | buffer_put_char(&msg, SSH2_FXP_OPEN); |
593 | buffer_put_int(&msg, id); | 596 | buffer_put_int(&msg, id); |
594 | buffer_put_cstring(&msg, remote_path); | 597 | buffer_put_cstring(&msg, remote_path); |
@@ -611,7 +614,7 @@ do_download(int fd_in, int fd_out, char *remote_path, char *local_path, | |||
611 | u_int len; | 614 | u_int len; |
612 | char *data; | 615 | char *data; |
613 | 616 | ||
614 | expected_id = ++id; | 617 | id = expected_id = msg_id++; |
615 | 618 | ||
616 | buffer_clear(&msg); | 619 | buffer_clear(&msg); |
617 | buffer_put_char(&msg, SSH2_FXP_READ); | 620 | buffer_put_char(&msg, SSH2_FXP_READ); |
@@ -713,7 +716,7 @@ do_upload(int fd_in, int fd_out, char *local_path, char *remote_path, | |||
713 | buffer_init(&msg); | 716 | buffer_init(&msg); |
714 | 717 | ||
715 | /* Send open request */ | 718 | /* Send open request */ |
716 | id = arc4random(); | 719 | id = msg_id++; |
717 | buffer_put_char(&msg, SSH2_FXP_OPEN); | 720 | buffer_put_char(&msg, SSH2_FXP_OPEN); |
718 | buffer_put_int(&msg, id); | 721 | buffer_put_int(&msg, id); |
719 | buffer_put_cstring(&msg, remote_path); | 722 | buffer_put_cstring(&msg, remote_path); |