diff options
author | Darren Tucker <dtucker@zip.com.au> | 2010-01-08 18:51:47 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2010-01-08 18:51:47 +1100 |
commit | b5082e90a13c9c9f96f1aed894f70f6f00737396 (patch) | |
tree | 188bbc53212f0e93f5ae6fe4a8f995c7052586ee | |
parent | 75694dbe77c56c127a2d2cfd443a0d591f441a55 (diff) |
- 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@
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | sftp.c | 8 |
2 files changed, 9 insertions, 4 deletions
@@ -99,6 +99,11 @@ | |||
99 | [roaming_common.c] | 99 | [roaming_common.c] |
100 | use socklen_t for getsockopt optlen parameter; reported by | 100 | use socklen_t for getsockopt optlen parameter; reported by |
101 | Steve.McClellan AT radisys.com, ok dtucker@ | 101 | Steve.McClellan AT radisys.com, ok dtucker@ |
102 | - dtucker@cvs.openbsd.org 2009/12/06 23:53:54 | ||
103 | [sftp.c] | ||
104 | fix potential divide-by-zero in sftp's "df" output when talking to a server | ||
105 | that reports zero files on the filesystem (Unix filesystems always have at | ||
106 | least the root inode). From Steve McClellan at radisys, ok djm@ | ||
102 | 107 | ||
103 | 20091226 | 108 | 20091226 |
104 | - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 | 109 | - (tim) [contrib/cygwin/Makefile] Install ssh-copy-id and ssh-copy-id.1 |
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp.c,v 1.113 2009/11/22 13:18:00 halex Exp $ */ | 1 | /* $OpenBSD: sftp.c,v 1.114 2009/12/06 23:53:54 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | 3 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
4 | * | 4 | * |
@@ -846,19 +846,19 @@ do_df(struct sftp_conn *conn, char *path, int hflag, int iflag) | |||
846 | char s_avail[FMT_SCALED_STRSIZE]; | 846 | char s_avail[FMT_SCALED_STRSIZE]; |
847 | char s_root[FMT_SCALED_STRSIZE]; | 847 | char s_root[FMT_SCALED_STRSIZE]; |
848 | char s_total[FMT_SCALED_STRSIZE]; | 848 | char s_total[FMT_SCALED_STRSIZE]; |
849 | unsigned long long ffree; | ||
849 | 850 | ||
850 | if (do_statvfs(conn, path, &st, 1) == -1) | 851 | if (do_statvfs(conn, path, &st, 1) == -1) |
851 | return -1; | 852 | return -1; |
852 | if (iflag) { | 853 | if (iflag) { |
854 | ffree = st.f_files ? (100 * (st.f_files - st.f_ffree) / st.f_files) : 0; | ||
853 | printf(" Inodes Used Avail " | 855 | printf(" Inodes Used Avail " |
854 | "(root) %%Capacity\n"); | 856 | "(root) %%Capacity\n"); |
855 | printf("%11llu %11llu %11llu %11llu %3llu%%\n", | 857 | printf("%11llu %11llu %11llu %11llu %3llu%%\n", |
856 | (unsigned long long)st.f_files, | 858 | (unsigned long long)st.f_files, |
857 | (unsigned long long)(st.f_files - st.f_ffree), | 859 | (unsigned long long)(st.f_files - st.f_ffree), |
858 | (unsigned long long)st.f_favail, | 860 | (unsigned long long)st.f_favail, |
859 | (unsigned long long)st.f_ffree, | 861 | (unsigned long long)st.f_ffree, ffree); |
860 | (unsigned long long)(100 * (st.f_files - st.f_ffree) / | ||
861 | st.f_files)); | ||
862 | } else if (hflag) { | 862 | } else if (hflag) { |
863 | strlcpy(s_used, "error", sizeof(s_used)); | 863 | strlcpy(s_used, "error", sizeof(s_used)); |
864 | strlcpy(s_avail, "error", sizeof(s_avail)); | 864 | strlcpy(s_avail, "error", sizeof(s_avail)); |