Bugs item #1878059, was opened at 2008-01-23 04:27
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1878059&group_id=125852
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Steven Ayre (stevenayre)
Assigned to: Nobody/Anonymous (nobody)
Summary: libssh2_scp_recv fails on large files
Initial Comment:
I am trying to download a 2,719,984,337 byte (2.5 GB) file using scp_get in Net::SSH2, but it fails with the error "Invalid response from SCP server, invalid size" (LIBSSH2_ERROR_SCP_PROTOCOL).
Upon investigation, the problem lies in libssh2 490 of src/scp.c (in CVS):
session->scpRecv_size = strtol(p, &e, 10);
This returns a ERANGE error as 2,719,984,337 is more than the 2,147,483,647 limit of a signed integer.
Is there any way to get the library to support files larger than this limit? I'm guessing it'll be more involved than changing the data type to long long and using strtoll?
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2008-04-09 07:04
Message:
Logged In: NO
The following change fixed the problem for me:
--- libssh2-0.18.org/src/libssh2_priv.h 2008-02-27 18:43:08.000000000
+0100
+++ libssh2-0.18/src/libssh2_priv.h 2008-03-20 17:50:19.000000000
+0100
@@ -811,7 +811,7 @@
unsigned char scpRecv_response[LIBSSH2_SCP_RESPONSE_BUFLEN];
unsigned long scpRecv_response_len;
long scpRecv_mode;
- long scpRecv_size;
+ off_t scpRecv_size;
long scpRecv_mtime;
long scpRecv_atime;
char *scpRecv_err_msg;
diff -ru libssh2-0.18.org/src/misc.c libssh2-0.18/src/misc.c
--- libssh2-0.18.org/src/misc.c 2008-02-27 18:43:10.000000000 +0100
+++ libssh2-0.18/src/misc.c 2008-03-20 18:37:33.000000000 +0100
@@ -62,7 +62,7 @@
msl = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
lsl = (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
- return ((msl * 65536) * 65536) + lsl;
+ return ((msl * (libssh2_uint64_t) 65536) * 65536) + lsl;
}
/* }}} */
diff -ru libssh2-0.18.org/src/scp.c libssh2-0.18/src/scp.c
--- libssh2-0.18.org/src/scp.c 2008-02-27 18:43:27.000000000 +0100
+++ libssh2-0.18/src/scp.c 2008-03-20 17:51:26.000000000 +0100
@@ -487,7 +487,7 @@
*(s++) = '\0';
/* Make sure we don't get fooled by leftover values */
errno = 0;
- session->scpRecv_size = strtol(p, &e, 10);
+ session->scpRecv_size = strtoull(p, &e, 10);
if ((e && *e) || errno) {
libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL,
"Invalid response from SCP server,
invalid size",
@@ -513,7 +513,7 @@
goto scp_recv_error;
}
_libssh2_debug(session, LIBSSH2_DBG_SCP,
- "mode = 0%lo size = %ld",
session->scpRecv_mode,
+ "mode = 0%lo size = %lld",
session->scpRecv_mode,
session->scpRecv_size);
/* We *should* check that basename is valid, but why let
that stop us? */
Additionally the library needs to get compiled with largefile support
enabled, e.g. by adding the output of the command "getconf LFS_CFLAGS" to
CFLAGS, "getconf LFS_LDFLAGS" to LDFLAGS, and "getconf LFS_LIBS" to LIBS,
respectively.
This causes the type "off_t" to be either 32 or 64 bit, as required on the
target platform.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1878059&group_id=125852
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2008-04-09