--- src/sftp.c	2005-06-18 00:15:50.000000000 +0700
+++ src/sftp.c.new	2006-09-03 18:54:22.000000000 +0700
@@ -693,11 +693,19 @@
 	}
 
 	switch (data[0]) {
-		case SSH_FXP_STATUS:
-			sftp->last_errno = libssh2_ntohu32(data + 5);
-			libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, "SFTP Protocol Error", 0);
+		case SSH_FXP_STATUS: {
+			int retcode;
+
+			retcode = libssh2_ntohu32(data + 5);
 			LIBSSH2_FREE(session, data);
-			return -1;
+			if (retcode == LIBSSH2_FX_EOF) {
+				return 0;
+			} else {
+				sftp->last_errno = retcode;
+				libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, "SFTP Protocol Error", 0);
+				return -1;
+			}
+		}
 		case SSH_FXP_DATA:
 			bytes_read = libssh2_ntohu32(data + 5);
 			if (bytes_read > (data_len - 9)) {


