diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-10-07 12:25:27 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-10-07 12:25:27 -0700 |
| commit | c2817955674c8cfc217c4ffc1deea8cc8cabe526 (patch) | |
| tree | 6330f51d8f3535d6f4fad01ce2573a801e70c1d8 /http.h | |
| parent | 6623b73ca69048e996112edf3e7a408ba6edaa43 (diff) | |
| parent | ecc5749578cea0d1c6072c806649bf1076c7b4c3 (diff) | |
| download | git-c2817955674c8cfc217c4ffc1deea8cc8cabe526.tar.xz | |
Merge branch 'js/curl-off-t-fixes'
A few places where an size_t value was cast to curl_off_t without
checking has been updated to use the existing helper function.
* js/curl-off-t-fixes:
http-push: avoid new compile error
imap-send: be more careful when casting to `curl_off_t`
http: offer to cast `size_t` to `curl_off_t` safely
Diffstat (limited to 'http.h')
| -rw-r--r-- | http.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -8,6 +8,7 @@ struct packed_git; #include <curl/curl.h> #include <curl/easy.h> +#include "gettext.h" #include "strbuf.h" #include "remote.h" @@ -95,6 +96,15 @@ static inline int missing__target(int code, int result) #define missing_target(a) missing__target((a)->http_code, (a)->curl_result) +static inline curl_off_t cast_size_t_to_curl_off_t(size_t a) +{ + uintmax_t size = a; + if (size > maximum_signed_value_of_type(curl_off_t)) + die(_("number too large to represent as curl_off_t " + "on this platform: %"PRIuMAX), (uintmax_t)a); + return (curl_off_t)a; +} + /* * Normalize curl results to handle CURL_FAILONERROR (or lack thereof). Failing * http codes have their "result" converted to CURLE_HTTP_RETURNED_ERROR, and |
