Subject: [libssh2] [ libssh2-Bugs-1908724 ] sftp 4GB stat problem

[libssh2] [ libssh2-Bugs-1908724 ] sftp 4GB stat problem

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Thu, 06 Mar 2008 04:41:47 -0800

Bugs item #1908724, was opened at 2008-03-06 12:41
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1908724&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: SFTP
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mike Protts (mikeprotts)
Assigned to: Nobody/Anonymous (nobody)
Summary: sftp 4GB stat problem

Initial Comment:
I have been working with libssh2 and curl and found a problem with the stat of a remote file that is larger than 4GB (curl uses this to decide when the transfer has finished). The attr size value returned from libssh2_sftp_stat is losing the hig bytes, therefore returning a size - 4GB instead of size.
 
The problem seems to be in misc.c function libssh2_ntohu64 where the return value is being calculated, and I think the compiler is performing calculations as 32 it instead of 64. I have a work around (below) which seems ok - comments welcome.
 
libssh2_uint64_t
libssh2_ntohu64(const unsigned char *buf)
{
   unsigned long lsl, msl;
   libssh2_uint64_t aval64; /* Used for return value */
 
   msl = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3];
   lsl = (buf[4] << 24) | (buf[5] << 16) | (buf[6] << 8) | buf[7];
   aval64 = msl; /* No cast needed as 32 to 64 bit should work */
   aval64 = aval64 * 65536 * 65536; /* now force to correct value */
   aval64 = aval64 + lsl; /* add 32 to 64 bit should be ok */
   return aval64; /*was ((msl * 65536) * 65536) + lsl;*/
}

In case this is thought to be a compiler issue, the compiler information
+follows:
mikep_at_rockwell:~/src/rexxcurl/RexxCURL-2.0$ uname -a
Linux rockwell 2.6.18-5-686 #1 SMP Wed Sep 26 17:54:59 UTC 2007 i686 GNU/Linux
mikep_at_rockwell:~/src/rexxcurl/RexxCURL-2.0$ gcc -v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
+--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
+--enable-shared --with-system-zlib --libexecdir=/usr/lib
+--without-included-gettext --enable-threads=posix --enable-nls
+--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
+--enable-libstdcxx-debug --enable-mpfr --with-tune=i686
+--enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
 

--
Regards
                                                                                
Mike Protts
Senior Technical Consultant
Pro:Atria Ltd
+44(0) 870 7656453
                                                                                
                                                                                           mikep_at_proatria.com

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1908724&group_id=125852

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2008-03-06