aboutsummaryrefslogtreecommitdiff
path: root/http.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-10-07 12:25:27 -0700
committerJunio C Hamano <gitster@pobox.com>2025-10-07 12:25:27 -0700
commitc2817955674c8cfc217c4ffc1deea8cc8cabe526 (patch)
tree6330f51d8f3535d6f4fad01ce2573a801e70c1d8 /http.h
parent6623b73ca69048e996112edf3e7a408ba6edaa43 (diff)
parentecc5749578cea0d1c6072c806649bf1076c7b4c3 (diff)
downloadgit-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.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/http.h b/http.h
index e5a5380c6c..553e16205c 100644
--- a/http.h
+++ b/http.h
@@ -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