]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
SMB: rangecheck values read off incoming packet
authorDaniel Stenberg <daniel@haxx.se>
Fri, 22 May 2015 08:28:21 +0000 (10:28 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 17 Jun 2015 05:43:13 +0000 (07:43 +0200)
CVE-2015-3237

Detected by Coverity. CID 1299430.

Bug: http://curl.haxx.se/docs/adv_20150617B.html

lib/smb.c

index 8cb350359ca642a381529d1d6c2acc30b557f443..d461a712cb9495892277f55e2b2bed83062c42d7 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -783,9 +783,15 @@ static CURLcode smb_request_state(struct connectdata *conn, bool *done)
     off = Curl_read16_le(((unsigned char *) msg) +
                          sizeof(struct smb_header) + 13);
     if(len > 0) {
-      result = Curl_client_write(conn, CLIENTWRITE_BODY,
-                                 (char *)msg + off + sizeof(unsigned int),
-                                 len);
+      struct smb_conn *smbc = &conn->proto.smbc;
+      if(off + sizeof(unsigned int) + len > smbc->got) {
+        failf(conn->data, "Invalid input packet");
+        result = CURLE_RECV_ERROR;
+      }
+      else
+        result = Curl_client_write(conn, CLIENTWRITE_BODY,
+                                   (char *)msg + off + sizeof(unsigned int),
+                                   len);
       if(result) {
         req->result = result;
         next_state = SMB_CLOSE;