Mark Roden wrote: > Out of a set of 65 files, maybe 1 will be corrupted like this, but > it's only happening 1 in 500 or so files.
Interesting issue. It should not be hard to fix once identified though. > Is there any chance that libssh2 could be responsible for this issue? Sure, there can be a bug in libssh2 causing this. > Is there a verbose checking mode, or is checking for transfer > success automatically done? As Daniel mentioned, the SSH protocol includes message authentication for every SSH packet sent, and TCP includes checksumming to make sure that SSH packets cross the net well. So the corruption will neccessarily come either from the sending or the receiving process, assuming that the two filesystems (on sender and receiver side) are not the cause. First find out exactly where and how the file has been corrupted; which offset does the corruption start at and can a pattern for the corruption be identified. (Some bit consistently wrong, are bytes missing or are there extra bytes moving the correct data forward or backward etc. etc.) In particular collect the above information for several failed runs, to determine if the problem has some consistent parameters. Ie. always at the same offset in the file, or always after sending the same total amount of bytes, or some other pattern. Then compile a libssh2 with debug messages enabled, and add to your program: libssh2_trace(session, LIBSSH2_TRACE_TRANS); which provides clear text data for packets sent and received. You can then match the data that is received with the data that libssh2 writes into the buffers that you provide for receiving data. Note that libssh2 return values work slightly differently from e.g. read() because libssh2 does not return the packet size until the full packet has actually been transferred. It could help to also add buffer debugging into your application, to verify that you see the exact same data that libssh2 sees. I'm attaching a function I use for this. Just #include "xxd.c" in file scope and then call xxd(buffer,length); I'd love to hear more details about this problem. If you've discovered a problem in libssh2 I think it's important that we fix it. Thanks! //Peter
#include <stdio.h> static void xxd(const unsigned char *s,size_t len) { size_t i,j; for(i=0;i<len;i+=16) { printf("%06x: ",i); for(j=0;j<16;j++) if(i+j<len) printf(" %02x",s[i+j]); else printf(" "); printf(" "); for(j=0;j<16&&i+j<len;j++) printf("%c",isprint(s[i+j])?s[i+j]:'.'); printf("\n"); } }
_______________________________________________ libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel