From e4eb716d2688f5c2d4615d79ad5f4f1eb50a9343 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 3 Apr 2026 01:40:39 +0200 Subject: turn all int offsets into size_t --- ot_http.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'ot_http.c') diff --git a/ot_http.c b/ot_http.c index a87a02e..a789f0d 100644 --- a/ot_http.c +++ b/ot_http.c @@ -141,13 +141,12 @@ ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { return ws->reply_size = -2; } -ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector, int is_partial) { +ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { struct http_data *cookie = io_getcookie(sock); io_batch *current; char *header; const char *encoding = ""; - int i; - size_t header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); + size_t i, header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); tai6464 t; /* No cookie? Bad socket. Leave. */ @@ -203,7 +202,7 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, int iovec iob_addbuf_free(current, header, header_size); /* Split huge iovectors into separate io_batches */ - for (i = 0; i < iovec_entries; ++i) { + for (i = 0; i < (size_t)iovec_entries; ++i) { /* If the current batch's limit is reached, try to reallocate a new batch to work on */ if (current->bytesleft > OT_BATCH_LIMIT) { io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); @@ -426,8 +425,9 @@ static ssize_t http_handle_fullscrape(const int64 sock, struct ot_workstruct *ws static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; - ot_hash *multiscrape_buf = (ot_hash *)ws->request; - int scanon = 1, numwant = 0; + ot_hash *multiscrape_buf = (ot_hash *)ws->request; + int scanon = 1; + size_t numwant = 0; /* This is to hack around stupid clients that send "scrape ?info_hash" */ if (read_ptr[-1] != '?') { @@ -502,7 +502,8 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", {"peer_id", 9}, {NULL, -3}}; static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { - int numwant, tmp, scanon; + size_t numwant; + int tmp, scanon; unsigned short port = 0; char *write_ptr; ssize_t len; @@ -578,8 +579,9 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * break; case 4: /* matched "numwant" */ len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); - if ((len <= 0) || scan_fixed_int(write_ptr, len, &numwant)) + if ((len <= 0) || scan_fixed_int(write_ptr, len, &tmp)) HTTPERROR_400_PARAM; + numwant = tmp; if (numwant < 0) numwant = 50; if (numwant > 200) -- cgit v1.2.3