Skip to content

Commit

Permalink
smb: Fixed a problem with large file transfers
Browse files Browse the repository at this point in the history
Fixed an issue with the message size calculation where the raw bytes
from the buffer were interpreted as signed values rather than unsigned
values.

Reported-by: Gisle Vanem
Assisted-by: Bill Nagel
  • Loading branch information
captain-caveman2k committed Dec 6, 2014
1 parent 36d45ea commit befe9a1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/smb.c
Expand Up @@ -266,11 +266,11 @@ static CURLcode smb_recv_message(struct connectdata *conn, void **msg)
msg_size = sizeof(struct smb_header);
if(nbt_size >= msg_size + 1) {
/* Add the word count */
msg_size += 1 + buf[msg_size] * sizeof(unsigned short);
msg_size += 1 + ((unsigned char) buf[msg_size]) * sizeof(unsigned short);
if(nbt_size >= msg_size + sizeof(unsigned short)) {
/* Add the byte count */
msg_size += sizeof(unsigned short) + buf[msg_size] +
(buf[msg_size + 1] << 8);
msg_size += sizeof(unsigned short) + ((unsigned char) buf[msg_size]) +
(((unsigned char) buf[msg_size + 1]) << 8);
if(nbt_size < msg_size)
return CURLE_READ_ERROR;
}
Expand Down

0 comments on commit befe9a1

Please sign in to comment.