diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2008-06-08 20:15:30 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2008-06-08 20:15:30 +0000 |
commit | 49b5c95286bc4e3a7b814ff0103fe63f5e3c8a5c (patch) | |
tree | b10b43c5f460d395600786e70c9fd81f73276865 /usr.bin | |
parent | e950c064fc206231bb48bf2a3303fc4e0b6b9ad1 (diff) |
Have the sftp client store the statvfs replies in wire format,
which prevents problems when the server's native sizes exceed the
client's.
Also extends the sizes of the remaining 32bit wire format to 64bit,
they're specified as unsigned long in the standard.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/PROTOCOL | 10 | ||||
-rw-r--r-- | usr.bin/ssh/sftp-client.c | 17 | ||||
-rw-r--r-- | usr.bin/ssh/sftp-client.h | 23 | ||||
-rw-r--r-- | usr.bin/ssh/sftp.c | 4 |
4 files changed, 36 insertions, 18 deletions
diff --git a/usr.bin/ssh/PROTOCOL b/usr.bin/ssh/PROTOCOL index 2cb45cfaa81..0e7b482bdad 100644 --- a/usr.bin/ssh/PROTOCOL +++ b/usr.bin/ssh/PROTOCOL @@ -133,8 +133,8 @@ These requests return a SSH_FXP_STATUS reply on failure. On success they return the following SSH_FXP_EXTENDED_REPLY reply: uint32 id - uint32 f_bsize /* file system block size */ - uint32 f_frsize /* fundamental fs block size */ + uint64 f_bsize /* file system block size */ + uint64 f_frsize /* fundamental fs block size */ uint64 f_blocks /* number of blocks (unit f_frsize) */ uint64 f_bfree /* free blocks in file system */ uint64 f_bavail /* free blocks for non-root */ @@ -142,8 +142,8 @@ return the following SSH_FXP_EXTENDED_REPLY reply: uint64 f_ffree /* free file inodes */ uint64 f_favail /* free file inodes for to non-root */ uint64 f_fsid /* file system id */ - uint32 f_flag /* bit mask of f_flag values */ - uint32 f_namemax /* maximum filename length */ + uint64 f_flag /* bit mask of f_flag values */ + uint64 f_namemax /* maximum filename length */ The values of the f_flag bitmask are as follows: @@ -153,5 +153,5 @@ The values of the f_flag bitmask are as follows: This extension is advertised in the SSH_FXP_VERSION hello with version "2". -$Id: PROTOCOL,v 1.3 2008/06/07 21:52:46 djm Exp $ +$Id: PROTOCOL,v 1.4 2008/06/08 20:15:29 dtucker Exp $ diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c index b414219d948..2bafd4de85f 100644 --- a/usr.bin/ssh/sftp-client.c +++ b/usr.bin/ssh/sftp-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.83 2008/06/07 21:52:46 djm Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.84 2008/06/08 20:15:29 dtucker Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * @@ -236,7 +236,8 @@ get_decode_stat(int fd, u_int expected_id, int quiet) } static int -get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet) +get_decode_statvfs(int fd, struct sftp_statvfs *st, u_int expected_id, + int quiet) { Buffer msg; u_int type, id, flag; @@ -265,8 +266,8 @@ get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet) } bzero(st, sizeof(*st)); - st->f_bsize = buffer_get_int(&msg); - st->f_frsize = buffer_get_int(&msg); + st->f_bsize = buffer_get_int64(&msg); + st->f_frsize = buffer_get_int64(&msg); st->f_blocks = buffer_get_int64(&msg); st->f_bfree = buffer_get_int64(&msg); st->f_bavail = buffer_get_int64(&msg); @@ -274,8 +275,8 @@ get_decode_statvfs(int fd, struct statvfs *st, u_int expected_id, int quiet) st->f_ffree = buffer_get_int64(&msg); st->f_favail = buffer_get_int64(&msg); st->f_fsid = buffer_get_int64(&msg); - flag = buffer_get_int(&msg); - st->f_namemax = buffer_get_int(&msg); + flag = buffer_get_int64(&msg); + st->f_namemax = buffer_get_int64(&msg); st->f_flag = (flag & SSH2_FXE_STATVFS_ST_RDONLY) ? ST_RDONLY : 0; st->f_flag |= (flag & SSH2_FXE_STATVFS_ST_NOSUID) ? ST_NOSUID : 0; @@ -804,7 +805,7 @@ do_readlink(struct sftp_conn *conn, char *path) #endif int -do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st, +do_statvfs(struct sftp_conn *conn, const char *path, struct sftp_statvfs *st, int quiet) { Buffer msg; @@ -832,7 +833,7 @@ do_statvfs(struct sftp_conn *conn, const char *path, struct statvfs *st, #ifdef notyet int do_fstatvfs(struct sftp_conn *conn, const char *handle, u_int handle_len, - struct statvfs *st, int quiet) + struct sftp_statvfs *st, int quiet) { Buffer msg; u_int id; diff --git a/usr.bin/ssh/sftp-client.h b/usr.bin/ssh/sftp-client.h index b102e118047..edb46790f3e 100644 --- a/usr.bin/ssh/sftp-client.h +++ b/usr.bin/ssh/sftp-client.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.h,v 1.16 2008/04/18 12:32:11 djm Exp $ */ +/* $OpenBSD: sftp-client.h,v 1.17 2008/06/08 20:15:29 dtucker Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> @@ -30,6 +30,24 @@ struct SFTP_DIRENT { }; /* + * Used for statvfs responses on the wire from the server, because the + * server's native format may be larger than the client's. + */ +struct sftp_statvfs { + u_int64_t f_bsize; + u_int64_t f_frsize; + u_int64_t f_blocks; + u_int64_t f_bfree; + u_int64_t f_bavail; + u_int64_t f_files; + u_int64_t f_ffree; + u_int64_t f_favail; + u_int64_t f_fsid; + u_int64_t f_flag; + u_int64_t f_namemax; +}; + +/* * Initialise a SSH filexfer connection. Returns NULL on error or * a pointer to a initialized sftp_conn struct on success. */ @@ -71,8 +89,7 @@ int do_fsetstat(struct sftp_conn *, char *, u_int, Attrib *); char *do_realpath(struct sftp_conn *, char *); /* Get statistics for filesystem hosting file at "path" */ -struct statvfs; -int do_statvfs(struct sftp_conn *, const char *, struct statvfs *, int); +int do_statvfs(struct sftp_conn *, const char *, struct sftp_statvfs *, int); /* Rename 'oldpath' to 'newpath' */ int do_rename(struct sftp_conn *, char *, char *); diff --git a/usr.bin/ssh/sftp.c b/usr.bin/ssh/sftp.c index aabe7c4eab9..1602f9b36d9 100644 --- a/usr.bin/ssh/sftp.c +++ b/usr.bin/ssh/sftp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.100 2008/04/18 12:32:11 djm Exp $ */ +/* $OpenBSD: sftp.c,v 1.101 2008/06/08 20:15:29 dtucker Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> * @@ -821,7 +821,7 @@ do_globbed_ls(struct sftp_conn *conn, char *path, char *strip_path, static int do_df(struct sftp_conn *conn, char *path, int hflag, int iflag) { - struct statvfs st; + struct sftp_statvfs st; char s_used[FMT_SCALED_STRSIZE]; char s_avail[FMT_SCALED_STRSIZE]; char s_root[FMT_SCALED_STRSIZE]; |