From 9ba51c79fa35b336ae6768b127e31b9214980dfb Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Tue, 3 May 2016 23:27:57 +0200 Subject: [PATCH] Fix uninitialized variable in Windows get_file_posn. The Windows implementation of get_file_posn is calling SetFilePointer to obtain the current position in the file. However it did not initialize the variable holding the high order 32-bit to 0. Thus, SetFilePointer either returned -1 to indicate an error or did move the file pointer to a different location instead of just returning the current position. This change just initializes the variable to 0. As a result, this bug has caused psftp's reget command to fail resuming transfers or to create corrupt files due to setting up an incorrect resume offset. --- windows/winsftp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/winsftp.c b/windows/winsftp.c index 525f0bf2..c786f7a6 100644 --- a/windows/winsftp.c +++ b/windows/winsftp.c @@ -244,7 +244,7 @@ int seek_file(WFile *f, uint64 offset, int whence) uint64 get_file_posn(WFile *f) { uint64 ret; - LONG lo, hi; + LONG lo, hi = 0; lo = SetFilePointer(f->h, 0L, &hi, FILE_CURRENT); ret.lo = lo; -- 2.45.2