]> git.ipfire.org Git - thirdparty/git.git/commitdiff
imap-send: be more careful when casting to `curl_off_t`
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 26 Sep 2025 10:32:51 +0000 (10:32 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Sep 2025 17:38:18 +0000 (10:38 -0700)
When casting a `size_t` to `curl_off_t`, there is a currently uncommon
chance that the value can be cut off (`curl_off_t` is expected to be a
signed 64-bit data type).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
imap-send.c

index 2e812f5a6e9e10d187507fa4458606bd5867680a..29dc86ff272ccc0dac2d032cc4c05b7f93557fbf 100644 (file)
@@ -1475,7 +1475,7 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,
                lf_to_crlf(&msgbuf.buf);
 
                curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
-                                (curl_off_t)(msgbuf.buf.len-prev_len));
+                                cast_size_t_to_curl_off_t(msgbuf.buf.len-prev_len));
 
                res = curl_easy_perform(curl);