diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-04-03 01:40:39 +0200 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-04-03 01:40:39 +0200 |
| commit | e4eb716d2688f5c2d4615d79ad5f4f1eb50a9343 (patch) | |
| tree | 5612056173478fecaad0a030195b6ed2f399df4d /ot_http.c | |
| parent | b20b0b89264e9d28ab873b8b1cc9ba73cdb58aeb (diff) | |
turn all int offsets into size_t
Diffstat (limited to 'ot_http.c')
| -rw-r--r-- | ot_http.c | 18 |
1 files changed, 10 insertions, 8 deletions
| @@ -141,13 +141,12 @@ ssize_t http_issue_error(const int64 sock, struct ot_workstruct *ws, int code) { | |||
| 141 | return ws->reply_size = -2; | 141 | return ws->reply_size = -2; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, int iovec_entries, struct iovec *iovector, int is_partial) { | 144 | ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, size_t iovec_entries, struct iovec *iovector, int is_partial) { |
| 145 | struct http_data *cookie = io_getcookie(sock); | 145 | struct http_data *cookie = io_getcookie(sock); |
| 146 | io_batch *current; | 146 | io_batch *current; |
| 147 | char *header; | 147 | char *header; |
| 148 | const char *encoding = ""; | 148 | const char *encoding = ""; |
| 149 | int i; | 149 | size_t i, header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); |
| 150 | size_t header_size, size = iovec_length(&iovec_entries, (const struct iovec **)&iovector); | ||
| 151 | tai6464 t; | 150 | tai6464 t; |
| 152 | 151 | ||
| 153 | /* No cookie? Bad socket. Leave. */ | 152 | /* No cookie? Bad socket. Leave. */ |
| @@ -203,7 +202,7 @@ ssize_t http_sendiovecdata(const int64 sock, struct ot_workstruct *ws, int iovec | |||
| 203 | iob_addbuf_free(current, header, header_size); | 202 | iob_addbuf_free(current, header, header_size); |
| 204 | 203 | ||
| 205 | /* Split huge iovectors into separate io_batches */ | 204 | /* Split huge iovectors into separate io_batches */ |
| 206 | for (i = 0; i < iovec_entries; ++i) { | 205 | for (i = 0; i < (size_t)iovec_entries; ++i) { |
| 207 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ | 206 | /* If the current batch's limit is reached, try to reallocate a new batch to work on */ |
| 208 | if (current->bytesleft > OT_BATCH_LIMIT) { | 207 | if (current->bytesleft > OT_BATCH_LIMIT) { |
| 209 | io_batch *new_batch = realloc(cookie->batch, (cookie->batches + 1) * sizeof(io_batch)); | 208 | 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 | |||
| 426 | static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 425 | static ssize_t http_handle_scrape(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
| 427 | static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; | 426 | static const ot_keywords keywords_scrape[] = {{"info_hash", 1}, {NULL, -3}}; |
| 428 | 427 | ||
| 429 | ot_hash *multiscrape_buf = (ot_hash *)ws->request; | 428 | ot_hash *multiscrape_buf = (ot_hash *)ws->request; |
| 430 | int scanon = 1, numwant = 0; | 429 | int scanon = 1; |
| 430 | size_t numwant = 0; | ||
| 431 | 431 | ||
| 432 | /* This is to hack around stupid clients that send "scrape ?info_hash" */ | 432 | /* This is to hack around stupid clients that send "scrape ?info_hash" */ |
| 433 | if (read_ptr[-1] != '?') { | 433 | if (read_ptr[-1] != '?') { |
| @@ -502,7 +502,8 @@ static ot_keywords keywords_announce[] = {{"port", 1}, {"left", 2}, {"event", | |||
| 502 | {"peer_id", 9}, {NULL, -3}}; | 502 | {"peer_id", 9}, {NULL, -3}}; |
| 503 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; | 503 | static ot_keywords keywords_announce_event[] = {{"completed", 1}, {"stopped", 2}, {NULL, -3}}; |
| 504 | static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { | 504 | static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct *ws, char *read_ptr) { |
| 505 | int numwant, tmp, scanon; | 505 | size_t numwant; |
| 506 | int tmp, scanon; | ||
| 506 | unsigned short port = 0; | 507 | unsigned short port = 0; |
| 507 | char *write_ptr; | 508 | char *write_ptr; |
| 508 | ssize_t len; | 509 | ssize_t len; |
| @@ -578,8 +579,9 @@ static ssize_t http_handle_announce(const int64 sock, struct ot_workstruct * | |||
| 578 | break; | 579 | break; |
| 579 | case 4: /* matched "numwant" */ | 580 | case 4: /* matched "numwant" */ |
| 580 | len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); | 581 | len = scan_urlencoded_query(&read_ptr, write_ptr = read_ptr, SCAN_SEARCHPATH_VALUE); |
| 581 | if ((len <= 0) || scan_fixed_int(write_ptr, len, &numwant)) | 582 | if ((len <= 0) || scan_fixed_int(write_ptr, len, &tmp)) |
| 582 | HTTPERROR_400_PARAM; | 583 | HTTPERROR_400_PARAM; |
| 584 | numwant = tmp; | ||
| 583 | if (numwant < 0) | 585 | if (numwant < 0) |
| 584 | numwant = 50; | 586 | numwant = 50; |
| 585 | if (numwant > 200) | 587 | if (numwant > 200) |
