From 93ae080bbc71c5281a35320c115546be2543a007 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 29 Sep 2008 14:04:01 +0000 Subject: [PATCH] - Based on a patch in bug #1878059 by Steven Ayre libssh2 now parses >2GB file sizes when downloading SCP files. --- NEWS | 6 +++++- configure.in | 7 ++++++- src/libssh2_priv.h | 9 ++++++++- src/scp.c | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 62d0f4c..9be751d 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,11 @@ Version 0.19 ( ) ------------------------------- -- Bug #2064371 pointed out that the SSH2 banner may not use dash ('-'). +- Based on a patch in bug #1878059 by Steven Ayre libssh2 now parses >2GB file + sizes when downloading SCP files. + +- Bug #2064371 pointed out that the SSH2 banner may not use dash ('-'). Reported + by Bjorn Stenborg. - Sean Peterson fixed a key re-exchange bug: http://daniel.haxx.se/projects/libssh2/mail/libssh2-devel-archive-2008-06/0002.shtml diff --git a/configure.in b/configure.in index a922d67..c40553b 100644 --- a/configure.in +++ b/configure.in @@ -40,6 +40,11 @@ case "$host" in ;; esac +AC_CHECK_TYPE(long long, + [AC_DEFINE(HAVE_LONGLONG, 1, + [Define to 1 if the compiler supports the 'long long' data type.])] + longlong="yes" +) # Some systems (Solaris?) have socket() in -lsocket. AC_SEARCH_LIBS(socket, socket) @@ -249,7 +254,7 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]), AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h]) AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h]) AC_CHECK_HEADERS([arpa/inet.h netinet/in.h]) -AC_CHECK_FUNCS(poll gettimeofday select) +AC_CHECK_FUNCS(poll gettimeofday select strtoll) AC_FUNC_ALLOCA diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index e49487e..4a5b6ec 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2007, Sara Golemon +/* Copyright (c) 2004-2008, Sara Golemon * All rights reserved. * * Redistribution and use in source and binary forms, @@ -811,7 +811,14 @@ struct _LIBSSH2_SESSION unsigned char scpRecv_response[LIBSSH2_SCP_RESPONSE_BUFLEN]; unsigned long scpRecv_response_len; long scpRecv_mode; +#if defined(HAVE_LONGLONG) && defined(strtoll) + /* we have the type and we can parse such numbers */ + long long scpRecv_size; +#define scpsize_strtol strtoll +#else long scpRecv_size; +#define scpsize_strtol strtol +#endif long scpRecv_mtime; long scpRecv_atime; char *scpRecv_err_msg; diff --git a/src/scp.c b/src/scp.c index 28eef5d..fac1bbd 100644 --- a/src/scp.c +++ b/src/scp.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2007, Sara Golemon +/* Copyright (c) 2004-2008, Sara Golemon * All rights reserved. * * Redistribution and use in source and binary forms, @@ -487,7 +487,7 @@ libssh2_scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb) *(s++) = '\0'; /* Make sure we don't get fooled by leftover values */ errno = 0; - session->scpRecv_size = strtol(p, &e, 10); + session->scpRecv_size = scpsize_strtol(p, &e, 10); if ((e && *e) || errno) { libssh2_error(session, LIBSSH2_ERROR_SCP_PROTOCOL, "Invalid response from SCP server, invalid size",