From c3d483f9a8275be1113535a1e0d0e384f605f3c4 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Fri, 17 Jan 2014 11:20:26 +1100 Subject: [PATCH] - (djm) [sftp-client.c] signed/unsigned comparison fix --- ChangeLog | 1 + sftp-client.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 880763a7d..ada012fb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ hardening flags including -fstack-protector-strong. These default to on if the toolchain supports them, but there is a configure-time knob (--without-hardening) to disable them if necessary. ok djm@ + - (djm) [sftp-client.c] signed/unsigned comparison fix 20140118 - (djm) OpenBSD CVS Sync diff --git a/sftp-client.c b/sftp-client.c index cb4e0c4b1..e3c630837 100644 --- a/sftp-client.c +++ b/sftp-client.c @@ -1104,7 +1104,11 @@ do_download(struct sftp_conn *conn, char *remote_path, char *local_path, local_path, strerror(errno)); goto fail; } - if (st.st_size > size) { + if (st.st_size < 0) { + error("\"%s\" has negative size", local_path); + goto fail; + } + if ((u_int64_t)st.st_size > size) { error("Unable to resume download of \"%s\": " "local file is larger than remote", local_path); fail: