mime: explicitly rewind subparts at attachment time.

Subparts may have been previously used as a top-level mime structure and
thus not rewound.

New test 695 checks the proper functioning in these particular conditions.

Reported-by: Qriist on github
Fixes #15842
Closes #15911
This commit is contained in:
Patrick Monnerat 2025-01-04 17:10:25 +01:00 committed by Daniel Stenberg
parent e602f7f119
commit 1b3f00f794
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 205 additions and 2 deletions

View file

@ -1561,6 +1561,14 @@ CURLcode Curl_mime_set_subparts(curl_mimepart *part,
}
}
/* If subparts have already been used as a top-level MIMEPOST,
they might not be positioned at start. Rewind them now, as
a future check while rewinding the parent may cause this
content to be skipped. */
if(mime_subparts_seek(subparts, (curl_off_t) 0, SEEK_SET) !=
CURL_SEEKFUNC_OK)
return CURLE_SEND_FAIL_REWIND;
subparts->parent = part;
/* Subparts are processed internally: no read callback. */
part->seekfunc = mime_subparts_seek;