016-CVE-2015-3237.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From d2f1a8bdce9d77a277d05adae025d369c1bdd9e6 Mon Sep 17 00:00:00 2001
  2. From: Daniel Stenberg <daniel@haxx.se>
  3. Date: Fri, 22 May 2015 10:28:21 +0200
  4. Subject: [PATCH] SMB: rangecheck values read off incoming packet
  5. CVE-2015-3237
  6. Detected by Coverity. CID 1299430.
  7. Bug: http://curl.haxx.se/docs/adv_20150617B.html
  8. ---
  9. lib/smb.c | 12 +++++++++---
  10. 1 file changed, 9 insertions(+), 3 deletions(-)
  11. --- a/lib/smb.c
  12. +++ b/lib/smb.c
  13. @@ -783,9 +783,15 @@ static CURLcode smb_request_state(struct
  14. off = Curl_read16_le(((unsigned char *) msg) +
  15. sizeof(struct smb_header) + 13);
  16. if(len > 0) {
  17. - result = Curl_client_write(conn, CLIENTWRITE_BODY,
  18. - (char *)msg + off + sizeof(unsigned int),
  19. - len);
  20. + struct smb_conn *smbc = &conn->proto.smbc;
  21. + if(off + sizeof(unsigned int) + len > smbc->got) {
  22. + failf(conn->data, "Invalid input packet");
  23. + result = CURLE_RECV_ERROR;
  24. + }
  25. + else
  26. + result = Curl_client_write(conn, CLIENTWRITE_BODY,
  27. + (char *)msg + off + sizeof(unsigned int),
  28. + len);
  29. if(result) {
  30. req->result = result;
  31. next_state = SMB_CLOSE;