]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
smb: adjust buffer size checks
authorDaniel Stenberg <daniel@haxx.se>
Thu, 18 Sep 2025 12:49:09 +0000 (14:49 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 18 Sep 2025 14:05:33 +0000 (16:05 +0200)
The checks did not account for the **two byte** 16bit read so risked
reading one more byte than what actually was received.

Reported-by: Joshua Rogers
Closes #18599

lib/smb.c

index 81cf6e7cc1f4707421b46ba03554d672c2f7b807..bf02119ea1dbd25e1a1b55426ce200ea5483c92a 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -1104,7 +1104,7 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done)
     break;
 
   case SMB_DOWNLOAD:
-    if(h->status || smbc->got < sizeof(struct smb_header) + 14) {
+    if(h->status || smbc->got < sizeof(struct smb_header) + 15) {
       req->result = CURLE_RECV_ERROR;
       next_state = SMB_CLOSE;
       break;
@@ -1133,7 +1133,7 @@ static CURLcode smb_request_state(struct Curl_easy *data, bool *done)
     break;
 
   case SMB_UPLOAD:
-    if(h->status || smbc->got < sizeof(struct smb_header) + 6) {
+    if(h->status || smbc->got < sizeof(struct smb_header) + 7) {
       req->result = CURLE_UPLOAD_FAILED;
       next_state = SMB_CLOSE;
       break;