Commit d23ad38a authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Fix heap corruption in smb_getattachment() for blank attachments

MSVC detected heap corruption from this function when the attachment was 0-bytes in length. Good catch.
parent acede36f
...@@ -545,7 +545,7 @@ uint8_t* smb_getattachment(smbmsg_t* msg, char* buf, char* filename, size_t file ...@@ -545,7 +545,7 @@ uint8_t* smb_getattachment(smbmsg_t* msg, char* buf, char* filename, size_t file
if(strStartsWith_i(msg->content_type, "multipart/") > 0) { if(strStartsWith_i(msg->content_type, "multipart/") > 0) {
txt = mime_getpart(buf, msg->content_type, /* match-type: */NULL, 0, &xfer_encoding, /* charset: */NULL txt = mime_getpart(buf, msg->content_type, /* match-type: */NULL, 0, &xfer_encoding, /* charset: */NULL
,/* attachment: */filename, filename_len, index); ,/* attachment: */filename, filename_len, index);
if(txt != NULL && xfer_encoding == CONTENT_TRANFER_ENCODING_BASE64) { if(txt != NULL && *txt && xfer_encoding == CONTENT_TRANFER_ENCODING_BASE64) {
size_t len = strlen(txt); size_t len = strlen(txt);
memmove(buf, txt, len + 1); memmove(buf, txt, len + 1);
int result = b64_decode(buf, len, buf, len); int result = b64_decode(buf, len, buf, len);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment