]> andersk Git - openssh.git/commitdiff
- dtucker@cvs.openbsd.org 2008/06/08 20:15:29
authordtucker <dtucker>
Mon, 9 Jun 2008 12:49:36 +0000 (12:49 +0000)
committerdtucker <dtucker>
Mon, 9 Jun 2008 12:49:36 +0000 (12:49 +0000)
     [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.

ChangeLog
sftp-client.c
sftp-client.h
sftp.c

index 4ec90f2f26ccf3f3dc04f29ed32bc72172246f98..9c4519df73a92bb1975ad34b7ff7011812b8186b 100644 (file)
--- 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
index 1fda576b486a122d8d0a6263bfa344fbb19efb71..8d0666b852712b3188d55356ab00a2b2cfb2ea2e 100644 (file)
@@ -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 @@ 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;
@@ -273,8 +274,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);
@@ -282,8 +283,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;
@@ -812,7 +813,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;
@@ -840,7 +841,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;
index b102e118047752715ca7ad8d648641b5501f2ffe..edb46790f3ed21858f2dbc39bdab82e47365d02a 100644 (file)
@@ -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>
@@ -29,6 +29,24 @@ struct SFTP_DIRENT {
        Attrib a;
 };
 
+/*
+ * 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/sftp.c b/sftp.c
index 50ac03798a7164a1cfe6ec3f717a2ab9c1398865..9b8bf389c51e8737f3ed1b7d77e5e2c01f5a66e1 100644 (file)
--- 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 @@ 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];
This page took 4.338038 seconds and 5 git commands to generate.