Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269964
b: refs/heads/master
c: 89482a5
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Layton committed Oct 19, 2011
1 parent 8346283 commit 4a2f403
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1041e3f9919999b22c9c2a453aa0d92cd16b76ee
refs/heads/master: 89482a56a079f01c2f4c709f8e23fbf7eeda1b43
31 changes: 24 additions & 7 deletions trunk/fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,25 @@ cifs_demultiplex_thread(void *p)
if (!is_smb_response(server, buf[0]))
continue;

/* check the length */
if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) ||
(pdu_length < sizeof(struct smb_hdr) - 1 - 4)) {
cERROR(1, "Invalid size SMB length %d pdu_length %d",
4, pdu_length + 4);
/* make sure we have enough to get to the MID */
if (pdu_length < sizeof(struct smb_hdr) - 1 - 4) {
cERROR(1, "SMB response too short (%u bytes)",
pdu_length);
cifs_reconnect(server);
wake_up(&server->response_q);
continue;
}

/* read down to the MID */
length = read_from_socket(server, buf + 4,
sizeof(struct smb_hdr) - 1 - 4);
if (length < 0)
continue;
total_read += length;

if (pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
cERROR(1, "SMB response too long (%u bytes)",
pdu_length);
cifs_reconnect(server);
wake_up(&server->response_q);
continue;
Expand All @@ -759,12 +773,15 @@ cifs_demultiplex_thread(void *p)
/* else length ok */
if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
isLargeBuf = true;
memcpy(bigbuf, smallbuf, 4);
memcpy(bigbuf, smallbuf, total_read);
smb_buffer = (struct smb_hdr *)bigbuf;
buf = bigbuf;
}

length = read_from_socket(server, buf + 4, pdu_length);
/* now read the rest */
length = read_from_socket(server,
buf + sizeof(struct smb_hdr) - 1,
pdu_length - sizeof(struct smb_hdr) + 1 + 4);
if (length < 0)
continue;
total_read += length;
Expand Down

0 comments on commit 4a2f403

Please sign in to comment.