mirror of
https://github.com/curl/curl.git
synced 2026-05-30 11:17:30 +03:00
smb: fix a size check to be overflow safe
In smb_send_message, although it could never actually overflow it might as well be done correctly. Also do the check earlier. Closes #19640
This commit is contained in:
parent
6aa8fa3fdf
commit
047b36d7a6
1 changed files with 3 additions and 3 deletions
|
|
@ -668,12 +668,12 @@ static CURLcode smb_send_message(struct Curl_easy *data,
|
|||
unsigned char cmd,
|
||||
const void *msg, size_t msg_len)
|
||||
{
|
||||
smb_format_message(smbc, req, (struct smb_header *)smbc->send_buf,
|
||||
cmd, msg_len);
|
||||
if((sizeof(struct smb_header) + msg_len) > MAX_MESSAGE_SIZE) {
|
||||
if((MAX_MESSAGE_SIZE - sizeof(struct smb_header)) < msg_len) {
|
||||
DEBUGASSERT(0);
|
||||
return CURLE_SEND_ERROR;
|
||||
}
|
||||
smb_format_message(smbc, req, (struct smb_header *)smbc->send_buf,
|
||||
cmd, msg_len);
|
||||
memcpy(smbc->send_buf + sizeof(struct smb_header), msg, msg_len);
|
||||
|
||||
return smb_send(data, smbc, sizeof(struct smb_header) + msg_len, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue