]> andersk Git - openssh.git/commitdiff
- dtucker@cvs.openbsd.org 2009/12/06 23:53:54
authordtucker <dtucker>
Fri, 8 Jan 2010 07:51:47 +0000 (07:51 +0000)
committerdtucker <dtucker>
Fri, 8 Jan 2010 07:51:47 +0000 (07:51 +0000)
     [sftp.c]
     fix potential divide-by-zero in sftp's "df" output when talking to a server
     that reports zero files on the filesystem (Unix filesystems always have at
     least the root inode).  From Steve McClellan at radisys, ok djm@

ChangeLog
sftp.c

index 94fb34c3b5d454eb7c34a05262c75500f2863d32..cb64d640ed4edff8732e9cbf03668cccc1961eaa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [roaming_common.c]
      use socklen_t for getsockopt optlen parameter; reported by
      Steve.McClellan AT radisys.com, ok dtucker@
+   - dtucker@cvs.openbsd.org 2009/12/06 23:53:54
+     [sftp.c]
+     fix potential divide-by-zero in sftp's "df" output when talking to a server
+     that reports zero files on the filesystem (Unix filesystems always have at
+     least the root inode).  From Steve McClellan at radisys, ok djm@
 
 20091226
  - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1
diff --git a/sftp.c b/sftp.c
index 2ce7cc1e1ef8099d9213fee88c0926a3be6229bf..1aa37423cba36932f9fa47e482c197eb3867a1f6 100644 (file)
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.113 2009/11/22 13:18:00 halex Exp $ */
+/* $OpenBSD: sftp.c,v 1.114 2009/12/06 23:53:54 dtucker Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
  *
@@ -846,19 +846,19 @@ do_df(struct sftp_conn *conn, char *path, int hflag, int iflag)
        char s_avail[FMT_SCALED_STRSIZE];
        char s_root[FMT_SCALED_STRSIZE];
        char s_total[FMT_SCALED_STRSIZE];
+       unsigned long long ffree;
 
        if (do_statvfs(conn, path, &st, 1) == -1)
                return -1;
        if (iflag) {
+               ffree = st.f_files ? (100 * (st.f_files - st.f_ffree) / st.f_files) : 0;
                printf("     Inodes        Used       Avail      "
                    "(root)    %%Capacity\n");
                printf("%11llu %11llu %11llu %11llu         %3llu%%\n",
                    (unsigned long long)st.f_files,
                    (unsigned long long)(st.f_files - st.f_ffree),
                    (unsigned long long)st.f_favail,
-                   (unsigned long long)st.f_ffree,
-                   (unsigned long long)(100 * (st.f_files - st.f_ffree) /
-                   st.f_files));
+                   (unsigned long long)st.f_ffree, ffree);
        } else if (hflag) {
                strlcpy(s_used, "error", sizeof(s_used));
                strlcpy(s_avail, "error", sizeof(s_avail));
This page took 0.255584 seconds and 5 git commands to generate.