summaryrefslogtreecommitdiff
path: root/sftp-server.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-06-23 21:27:18 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-06-23 21:27:18 +0000
commitb1f483f472da5fd2dbcb009d9988088f43c21579 (patch)
tree2d3f0c9906f6bb38e2d8f1e2a8f673191fdd3769 /sftp-server.c
parent5c3855210ef20be5931d4b58f641d71bc3b203e8 (diff)
- deraadt@cvs.openbsd.org 2002/06/23 09:30:14
[sftp-client.c sftp-client.h sftp-common.c sftp-int.c sftp-server.c sftp.c] bunch of u_int vs int stuff
Diffstat (limited to 'sftp-server.c')
-rw-r--r--sftp-server.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/sftp-server.c b/sftp-server.c
index 9db28e7d3..c3eee3802 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: sftp-server.c,v 1.35 2002/06/06 17:30:11 markus Exp $"); 25RCSID("$OpenBSD: sftp-server.c,v 1.36 2002/06/23 09:30:14 deraadt Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "bufaux.h" 28#include "bufaux.h"
@@ -282,7 +282,7 @@ send_status(u_int32_t id, u_int32_t error)
282 "Unknown error" /* Others */ 282 "Unknown error" /* Others */
283 }; 283 };
284 284
285 TRACE("sent status id %d error %d", id, error); 285 TRACE("sent status id %u error %u", id, error);
286 buffer_init(&msg); 286 buffer_init(&msg);
287 buffer_put_char(&msg, SSH2_FXP_STATUS); 287 buffer_put_char(&msg, SSH2_FXP_STATUS);
288 buffer_put_int(&msg, id); 288 buffer_put_int(&msg, id);
@@ -311,7 +311,7 @@ send_data_or_handle(char type, u_int32_t id, char *data, int dlen)
311static void 311static void
312send_data(u_int32_t id, char *data, int dlen) 312send_data(u_int32_t id, char *data, int dlen)
313{ 313{
314 TRACE("sent data id %d len %d", id, dlen); 314 TRACE("sent data id %u len %d", id, dlen);
315 send_data_or_handle(SSH2_FXP_DATA, id, data, dlen); 315 send_data_or_handle(SSH2_FXP_DATA, id, data, dlen);
316} 316}
317 317
@@ -322,7 +322,7 @@ send_handle(u_int32_t id, int handle)
322 int hlen; 322 int hlen;
323 323
324 handle_to_string(handle, &string, &hlen); 324 handle_to_string(handle, &string, &hlen);
325 TRACE("sent handle id %d handle %d", id, handle); 325 TRACE("sent handle id %u handle %d", id, handle);
326 send_data_or_handle(SSH2_FXP_HANDLE, id, string, hlen); 326 send_data_or_handle(SSH2_FXP_HANDLE, id, string, hlen);
327 xfree(string); 327 xfree(string);
328} 328}
@@ -337,7 +337,7 @@ send_names(u_int32_t id, int count, Stat *stats)
337 buffer_put_char(&msg, SSH2_FXP_NAME); 337 buffer_put_char(&msg, SSH2_FXP_NAME);
338 buffer_put_int(&msg, id); 338 buffer_put_int(&msg, id);
339 buffer_put_int(&msg, count); 339 buffer_put_int(&msg, count);
340 TRACE("sent names id %d count %d", id, count); 340 TRACE("sent names id %u count %d", id, count);
341 for (i = 0; i < count; i++) { 341 for (i = 0; i < count; i++) {
342 buffer_put_cstring(&msg, stats[i].name); 342 buffer_put_cstring(&msg, stats[i].name);
343 buffer_put_cstring(&msg, stats[i].long_name); 343 buffer_put_cstring(&msg, stats[i].long_name);
@@ -352,7 +352,7 @@ send_attrib(u_int32_t id, Attrib *a)
352{ 352{
353 Buffer msg; 353 Buffer msg;
354 354
355 TRACE("sent attrib id %d have 0x%x", id, a->flags); 355 TRACE("sent attrib id %u have 0x%x", id, a->flags);
356 buffer_init(&msg); 356 buffer_init(&msg);
357 buffer_put_char(&msg, SSH2_FXP_ATTRS); 357 buffer_put_char(&msg, SSH2_FXP_ATTRS);
358 buffer_put_int(&msg, id); 358 buffer_put_int(&msg, id);
@@ -391,7 +391,7 @@ process_open(void)
391 a = get_attrib(); 391 a = get_attrib();
392 flags = flags_from_portable(pflags); 392 flags = flags_from_portable(pflags);
393 mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666; 393 mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? a->perm : 0666;
394 TRACE("open id %d name %s flags %d mode 0%o", id, name, pflags, mode); 394 TRACE("open id %u name %s flags %d mode 0%o", id, name, pflags, mode);
395 fd = open(name, flags, mode); 395 fd = open(name, flags, mode);
396 if (fd < 0) { 396 if (fd < 0) {
397 status = errno_to_portable(errno); 397 status = errno_to_portable(errno);
@@ -417,7 +417,7 @@ process_close(void)
417 417
418 id = get_int(); 418 id = get_int();
419 handle = get_handle(); 419 handle = get_handle();
420 TRACE("close id %d handle %d", id, handle); 420 TRACE("close id %u handle %d", id, handle);
421 ret = handle_close(handle); 421 ret = handle_close(handle);
422 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; 422 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
423 send_status(id, status); 423 send_status(id, status);
@@ -436,7 +436,7 @@ process_read(void)
436 off = get_int64(); 436 off = get_int64();
437 len = get_int(); 437 len = get_int();
438 438
439 TRACE("read id %d handle %d off %llu len %d", id, handle, 439 TRACE("read id %u handle %d off %llu len %d", id, handle,
440 (u_int64_t)off, len); 440 (u_int64_t)off, len);
441 if (len > sizeof buf) { 441 if (len > sizeof buf) {
442 len = sizeof buf; 442 len = sizeof buf;
@@ -477,7 +477,7 @@ process_write(void)
477 off = get_int64(); 477 off = get_int64();
478 data = get_string(&len); 478 data = get_string(&len);
479 479
480 TRACE("write id %d handle %d off %llu len %d", id, handle, 480 TRACE("write id %u handle %d off %llu len %d", id, handle,
481 (u_int64_t)off, len); 481 (u_int64_t)off, len);
482 fd = handle_to_fd(handle); 482 fd = handle_to_fd(handle);
483 if (fd >= 0) { 483 if (fd >= 0) {
@@ -512,7 +512,7 @@ process_do_stat(int do_lstat)
512 512
513 id = get_int(); 513 id = get_int();
514 name = get_string(NULL); 514 name = get_string(NULL);
515 TRACE("%sstat id %d name %s", do_lstat ? "l" : "", id, name); 515 TRACE("%sstat id %u name %s", do_lstat ? "l" : "", id, name);
516 ret = do_lstat ? lstat(name, &st) : stat(name, &st); 516 ret = do_lstat ? lstat(name, &st) : stat(name, &st);
517 if (ret < 0) { 517 if (ret < 0) {
518 status = errno_to_portable(errno); 518 status = errno_to_portable(errno);
@@ -548,7 +548,7 @@ process_fstat(void)
548 548
549 id = get_int(); 549 id = get_int();
550 handle = get_handle(); 550 handle = get_handle();
551 TRACE("fstat id %d handle %d", id, handle); 551 TRACE("fstat id %u handle %d", id, handle);
552 fd = handle_to_fd(handle); 552 fd = handle_to_fd(handle);
553 if (fd >= 0) { 553 if (fd >= 0) {
554 ret = fstat(fd, &st); 554 ret = fstat(fd, &st);
@@ -582,13 +582,12 @@ process_setstat(void)
582 Attrib *a; 582 Attrib *a;
583 u_int32_t id; 583 u_int32_t id;
584 char *name; 584 char *name;
585 int ret; 585 int status = SSH2_FX_OK, ret;
586 int status = SSH2_FX_OK;
587 586
588 id = get_int(); 587 id = get_int();
589 name = get_string(NULL); 588 name = get_string(NULL);
590 a = get_attrib(); 589 a = get_attrib();
591 TRACE("setstat id %d name %s", id, name); 590 TRACE("setstat id %u name %s", id, name);
592 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) { 591 if (a->flags & SSH2_FILEXFER_ATTR_SIZE) {
593 ret = truncate(name, a->size); 592 ret = truncate(name, a->size);
594 if (ret == -1) 593 if (ret == -1)
@@ -625,7 +624,7 @@ process_fsetstat(void)
625 id = get_int(); 624 id = get_int();
626 handle = get_handle(); 625 handle = get_handle();
627 a = get_attrib(); 626 a = get_attrib();
628 TRACE("fsetstat id %d handle %d", id, handle); 627 TRACE("fsetstat id %u handle %d", id, handle);
629 fd = handle_to_fd(handle); 628 fd = handle_to_fd(handle);
630 name = handle_to_name(handle); 629 name = handle_to_name(handle);
631 if (fd < 0 || name == NULL) { 630 if (fd < 0 || name == NULL) {
@@ -677,7 +676,7 @@ process_opendir(void)
677 676
678 id = get_int(); 677 id = get_int();
679 path = get_string(NULL); 678 path = get_string(NULL);
680 TRACE("opendir id %d path %s", id, path); 679 TRACE("opendir id %u path %s", id, path);
681 dirp = opendir(path); 680 dirp = opendir(path);
682 if (dirp == NULL) { 681 if (dirp == NULL) {
683 status = errno_to_portable(errno); 682 status = errno_to_portable(errno);
@@ -713,13 +712,13 @@ ls_file(char *name, struct stat *st)
713 if ((pw = getpwuid(st->st_uid)) != NULL) { 712 if ((pw = getpwuid(st->st_uid)) != NULL) {
714 user = pw->pw_name; 713 user = pw->pw_name;
715 } else { 714 } else {
716 snprintf(ubuf, sizeof ubuf, "%d", st->st_uid); 715 snprintf(ubuf, sizeof ubuf, "%u", st->st_uid);
717 user = ubuf; 716 user = ubuf;
718 } 717 }
719 if ((gr = getgrgid(st->st_gid)) != NULL) { 718 if ((gr = getgrgid(st->st_gid)) != NULL) {
720 group = gr->gr_name; 719 group = gr->gr_name;
721 } else { 720 } else {
722 snprintf(gbuf, sizeof gbuf, "%d", st->st_gid); 721 snprintf(gbuf, sizeof gbuf, "%u", st->st_gid);
723 group = gbuf; 722 group = gbuf;
724 } 723 }
725 if (ltime != NULL) { 724 if (ltime != NULL) {
@@ -749,7 +748,7 @@ process_readdir(void)
749 748
750 id = get_int(); 749 id = get_int();
751 handle = get_handle(); 750 handle = get_handle();
752 TRACE("readdir id %d handle %d", id, handle); 751 TRACE("readdir id %u handle %d", id, handle);
753 dirp = handle_to_dir(handle); 752 dirp = handle_to_dir(handle);
754 path = handle_to_name(handle); 753 path = handle_to_name(handle);
755 if (dirp == NULL || path == NULL) { 754 if (dirp == NULL || path == NULL) {
@@ -759,6 +758,7 @@ process_readdir(void)
759 char pathname[1024]; 758 char pathname[1024];
760 Stat *stats; 759 Stat *stats;
761 int nstats = 10, count = 0, i; 760 int nstats = 10, count = 0, i;
761
762 stats = xmalloc(nstats * sizeof(Stat)); 762 stats = xmalloc(nstats * sizeof(Stat));
763 while ((dp = readdir(dirp)) != NULL) { 763 while ((dp = readdir(dirp)) != NULL) {
764 if (count >= nstats) { 764 if (count >= nstats) {
@@ -802,7 +802,7 @@ process_remove(void)
802 802
803 id = get_int(); 803 id = get_int();
804 name = get_string(NULL); 804 name = get_string(NULL);
805 TRACE("remove id %d name %s", id, name); 805 TRACE("remove id %u name %s", id, name);
806 ret = unlink(name); 806 ret = unlink(name);
807 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; 807 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
808 send_status(id, status); 808 send_status(id, status);
@@ -822,7 +822,7 @@ process_mkdir(void)
822 a = get_attrib(); 822 a = get_attrib();
823 mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ? 823 mode = (a->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) ?
824 a->perm & 0777 : 0777; 824 a->perm & 0777 : 0777;
825 TRACE("mkdir id %d name %s mode 0%o", id, name, mode); 825 TRACE("mkdir id %u name %s mode 0%o", id, name, mode);
826 ret = mkdir(name, mode); 826 ret = mkdir(name, mode);
827 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; 827 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
828 send_status(id, status); 828 send_status(id, status);
@@ -838,7 +838,7 @@ process_rmdir(void)
838 838
839 id = get_int(); 839 id = get_int();
840 name = get_string(NULL); 840 name = get_string(NULL);
841 TRACE("rmdir id %d name %s", id, name); 841 TRACE("rmdir id %u name %s", id, name);
842 ret = rmdir(name); 842 ret = rmdir(name);
843 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; 843 status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK;
844 send_status(id, status); 844 send_status(id, status);
@@ -858,7 +858,7 @@ process_realpath(void)
858 xfree(path); 858 xfree(path);
859 path = xstrdup("."); 859 path = xstrdup(".");
860 } 860 }
861 TRACE("realpath id %d path %s", id, path); 861 TRACE("realpath id %u path %s", id, path);
862 if (realpath(path, resolvedname) == NULL) { 862 if (realpath(path, resolvedname) == NULL) {
863 send_status(id, errno_to_portable(errno)); 863 send_status(id, errno_to_portable(errno));
864 } else { 864 } else {
@@ -881,7 +881,7 @@ process_rename(void)
881 id = get_int(); 881 id = get_int();
882 oldpath = get_string(NULL); 882 oldpath = get_string(NULL);
883 newpath = get_string(NULL); 883 newpath = get_string(NULL);
884 TRACE("rename id %d old %s new %s", id, oldpath, newpath); 884 TRACE("rename id %u old %s new %s", id, oldpath, newpath);
885 /* fail if 'newpath' exists */ 885 /* fail if 'newpath' exists */
886 if (stat(newpath, &st) == -1) { 886 if (stat(newpath, &st) == -1) {
887 ret = rename(oldpath, newpath); 887 ret = rename(oldpath, newpath);
@@ -902,7 +902,7 @@ process_readlink(void)
902 902
903 id = get_int(); 903 id = get_int();
904 path = get_string(NULL); 904 path = get_string(NULL);
905 TRACE("readlink id %d path %s", id, path); 905 TRACE("readlink id %u path %s", id, path);
906 if ((len = readlink(path, link, sizeof(link) - 1)) == -1) 906 if ((len = readlink(path, link, sizeof(link) - 1)) == -1)
907 send_status(id, errno_to_portable(errno)); 907 send_status(id, errno_to_portable(errno));
908 else { 908 else {
@@ -927,7 +927,7 @@ process_symlink(void)
927 id = get_int(); 927 id = get_int();
928 oldpath = get_string(NULL); 928 oldpath = get_string(NULL);
929 newpath = get_string(NULL); 929 newpath = get_string(NULL);
930 TRACE("symlink id %d old %s new %s", id, oldpath, newpath); 930 TRACE("symlink id %u old %s new %s", id, oldpath, newpath);
931 /* fail if 'newpath' exists */ 931 /* fail if 'newpath' exists */
932 if (stat(newpath, &st) == -1) { 932 if (stat(newpath, &st) == -1) {
933 ret = symlink(oldpath, newpath); 933 ret = symlink(oldpath, newpath);