- dtucker@cvs.openbsd.org 2008/06/08 20:15:29
     [sftp.c sftp-client.c sftp-client.h]
     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.
diff --git a/ChangeLog b/ChangeLog
index f183a83..88be1a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,13 @@
    - dtucker@cvs.openbsd.org 2008/06/08 17:04:41
      [sftp-server.c]
      Add case for ENOSYS in errno_to_portable; ok deraadt
+   - dtucker@cvs.openbsd.org 2008/06/08 20:15:29
+     [sftp.c sftp-client.c sftp-client.h]
+     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.
 
 20080608
  - (dtucker) [configure.ac defines.h sftp-client.c sftp-server.c sftp.c
@@ -4069,4 +4076,4 @@
    OpenServer 6 and add osr5bigcrypt support so when someone migrates
    passwords between UnixWare and OpenServer they will still work. OK dtucker@
 
-$Id: ChangeLog,v 1.4945 2008/06/09 12:48:31 dtucker Exp $
+$Id: ChangeLog,v 1.4946 2008/06/09 12:49:36 dtucker Exp $
diff --git a/sftp-client.c b/sftp-client.c
index 1fda576..8d0666b 100644
--- a/sftp-client.c
+++ b/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>
  *
@@ -244,7 +244,8 @@
 }
 
 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;
@@ -273,8 +274,8 @@
 	}
 
 	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);
@@ -282,8 +283,8 @@
 	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;
@@ -812,7 +813,7 @@
 #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;
@@ -840,7 +841,7 @@
 #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/sftp-client.h b/sftp-client.h
index b102e11..edb4679 100644
--- a/sftp-client.h
+++ b/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 @@
 };
 
 /*
+ * 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 @@
 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/sftp.c b/sftp.c
index 50ac037..9b8bf38 100644
--- a/sftp.c
+++ b/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>
  *
@@ -842,7 +842,7 @@
 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];