diff options
author | Jeff King <peff@peff.net> | 2017-03-28 15:46:56 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-30 14:59:50 -0700 |
commit | 1a168e5c86d2c6cbb57429473357bdf1acdec63c (patch) | |
tree | 7a22f1e29fad8eb65e1fb7e9eec01bd10c37716b /http.c | |
parent | 0dc3b035e03a4028a22cd2a8b5f21086e3227047 (diff) | |
download | git-1a168e5c86d2c6cbb57429473357bdf1acdec63c.tar.gz |
convert unchecked snprintf into xsnprintf
These calls to snprintf should always succeed, because their
input is small and fixed. Let's use xsnprintf to make sure
this is the case (and to make auditing for actual truncation
easier).
These could be candidates for turning into heap buffers, but
they fall into a few broad categories that make it not worth
doing:
- formatting single numbers is simple enough that we can
see the result should fit
- the size of a sha1 is likewise well-known, and I didn't
want to cause unnecessary conflicts with the ongoing
process to convert these constants to GIT_MAX_HEXSZ
- the interface for curl_errorstr is dictated by curl
Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1366,9 +1366,9 @@ static int handle_curl_result(struct slot_results *results) * FAILONERROR it is lost, so we can give only the numeric * status code. */ - snprintf(curl_errorstr, sizeof(curl_errorstr), - "The requested URL returned error: %ld", - results->http_code); + xsnprintf(curl_errorstr, sizeof(curl_errorstr), + "The requested URL returned error: %ld", + results->http_code); } if (results->curl_result == CURLE_OK) { @@ -1410,8 +1410,8 @@ int run_one_slot(struct active_request_slot *slot, { slot->results = results; if (!start_active_slot(slot)) { - snprintf(curl_errorstr, sizeof(curl_errorstr), - "failed to start HTTP request"); + xsnprintf(curl_errorstr, sizeof(curl_errorstr), + "failed to start HTTP request"); return HTTP_START_FAILED; } |