summaryrefslogtreecommitdiff
path: root/src/ot_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ot_http.c')
-rw-r--r--src/ot_http.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/ot_http.c b/src/ot_http.c
index 70176c3..2e21546 100644
--- a/src/ot_http.c
+++ b/src/ot_http.c
@@ -141,9 +141,9 @@ static void http_senddata(const int64_t sock, struct ot_workstruct *ws) {
141 141
142 batch_add(cookie->batch, outbuf, ws->reply_size - written_size); 142 batch_add(cookie->batch, outbuf, ws->reply_size - written_size);
143 143
144 /* writeable short data sockets just have a tcp timeout */ 144 /* Reset any connections potentially near their timeout */
145 if (!ws->keep_alive) 145 if (!ws->keep_alive)
146 fdstate_set_expiry(sock, 0); 146 fdstate_set_expiry(sock, time_future_seconds(OT_CLIENT_TIMEOUT_SEND));
147 http_interest_set(sock, cookie, EVENT_OUT); 147 http_interest_set(sock, cookie, EVENT_OUT);
148 } 148 }
149} 149}
@@ -536,7 +536,7 @@ static ssize_t http_handle_scrape(const int64_t sock, struct ot_workstruct *ws,
536 qsort(multiscrape_buf, numwant, sizeof(ot_hash), compare_hash); 536 qsort(multiscrape_buf, numwant, sizeof(ot_hash), compare_hash);
537 for (i = unique = 1; i < numwant; ++i) 537 for (i = unique = 1; i < numwant; ++i)
538 if (memcmp(multiscrape_buf[i], multiscrape_buf[unique - 1], sizeof(ot_hash))) 538 if (memcmp(multiscrape_buf[i], multiscrape_buf[unique - 1], sizeof(ot_hash)))
539 memcpy(multiscrape_buf[unique++], multiscrape_buf[i], sizeof(ot_hash)); 539 memmove(multiscrape_buf[unique++], multiscrape_buf[i], sizeof(ot_hash));
540 numwant = unique; 540 numwant = unique;
541 541
542 /* Enough for http header + whole scrape string */ 542 /* Enough for http header + whole scrape string */
@@ -634,7 +634,7 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct
634 break; 634 break;
635 case 1: /* matched "port" */ 635 case 1: /* matched "port" */
636 len = urlencoded_parse(&read_ptr, write_ptr = read_ptr, ws->request + ws->request_size, SCAN_SEARCHPATH_VALUE); 636 len = urlencoded_parse(&read_ptr, write_ptr = read_ptr, ws->request + ws->request_size, SCAN_SEARCHPATH_VALUE);
637 if ((len <= 0) || scan_int(write_ptr, len, &tmp) || (tmp > 0xffff)) 637 if ((len <= 0) || scan_int(write_ptr, len, &tmp) || (tmp < 0) || (tmp > 0xffff))
638 HTTPERROR_400_PARAM; 638 HTTPERROR_400_PARAM;
639 port = htons((uint16_t)tmp); 639 port = htons((uint16_t)tmp);
640 OT_SETPORT(&ws->peer, &port); 640 OT_SETPORT(&ws->peer, &port);
@@ -690,7 +690,8 @@ static ssize_t http_handle_announce(const int64_t sock, struct ot_workstruct
690 case 7: /* matched "ip" */ 690 case 7: /* matched "ip" */
691 { 691 {
692 char *tmp_buf1 = ws->reply, *tmp_buf2 = ws->reply + 16; 692 char *tmp_buf1 = ws->reply, *tmp_buf2 = ws->reply + 16;
693 len = urlencoded_parse(&read_ptr, tmp_buf2, ws->outbuf + G_OUTBUF_SIZE, SCAN_SEARCHPATH_VALUE); 693 /* One short of the end, for the terminator below */
694 len = urlencoded_parse(&read_ptr, tmp_buf2, ws->outbuf + G_OUTBUF_SIZE - 1, SCAN_SEARCHPATH_VALUE);
694 if (len <= 0) 695 if (len <= 0)
695 HTTPERROR_400_PARAM; 696 HTTPERROR_400_PARAM;
696 tmp_buf2[len] = 0; 697 tmp_buf2[len] = 0;