Re: [libssh2] libssh2_sftp_read* bug

2007-02-14 Thread Daniel Stenberg
On Tue, 13 Feb 2007, Lucas Newman wrote: > Here's a patch that addresses it. Thanks a lot. How about this minor rewrite of it, to make the logic somewhat easier to follow (at least in my brain): --- src/transport.c 2 Feb 2007 23:23:37 - 1.2 +++ src/transport.c 14 Feb 2007 12:4

Re: [libssh2] libssh2_sftp_read* bug

2007-02-13 Thread Lucas Newman
And I just realized that it was an earlier version of the patch which subtracted from the write index, so ignore me :) I would like feedback on the patch though. -Lucas On Feb 13, 2007, at 3:49 PM, Lucas Newman wrote: > Here's a patch that addresses it. You may want to do it differently >

Re: [libssh2] libssh2_sftp_read* bug

2007-02-13 Thread Lucas Newman
Here's a patch that addresses it. You may want to do it differently though, as subtracting from the write index is a little weird, but I couldn't see how else to do it since we need to determine padding length from the first block. -Lucas Index: transport.c

Re: [libssh2] libssh2_sftp_read* bug

2007-02-13 Thread Daniel Stenberg
On Tue, 13 Feb 2007, Lucas Newman wrote: > This loop will process 1440 bytes of data that we passed in, and then 8 > bytes are left in the buffer. However, we didn't outside of this function > we assumed that all 1448 bytes were processed and copied into the decrypted > packet buffer. > > Back

Re: [libssh2] libssh2_sftp_read* bug

2007-02-13 Thread Lucas Newman
Consider the case where we ask for 4000 bytes in a read. From the recv where data is grabbed off the network, you are given 1448 bytes in the first chunk. This is enough data to decrypt, so in transport.c, this call is made: rc = decrypt(session, &p->buf[p->readidx], p->wptr, numdecrypt);

Re: [libssh2] libssh2_sftp_read* bug

2007-02-13 Thread Daniel Stenberg
On Mon, 12 Feb 2007, Lucas Newman wrote: > I think I understand what is happening now. If a large read blocks in the > middle, the chunk of data obtained is processed in transport.c to determine > if a full packet was snagged. While processing half of a packet, if the > data is not a multiple

Re: [libssh2] libssh2_sftp_read* bug

2007-02-12 Thread Lucas Newman
I think I understand what is happening now. If a large read blocks in the middle, the chunk of data obtained is processed in transport.c to determine if a full packet was snagged. While processing half of a packet, if the data is not a multiple of the crypto block size, the extra bytes ar

Re: [libssh2] libssh2_sftp_read* bug

2007-02-12 Thread Lucas Newman
As a followup to the bug I reported yesterday, I have found some more issues in the packet handling with the latest code in CVS. For one, in the transportpacket structure, the total_num field is an integer, so if the packet is corrupted (this is happening with large SFTP reads – I'm still