mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
get rid of the scary 256-byte-buf landmine
This commit is contained in:
parent
eb429232ef
commit
771fb7e7ba
1 changed files with 6 additions and 8 deletions
|
@ -3479,7 +3479,7 @@ static void
|
||||||
write_http_status_line(dir_connection_t *conn, int status,
|
write_http_status_line(dir_connection_t *conn, int status,
|
||||||
const char *reason_phrase)
|
const char *reason_phrase)
|
||||||
{
|
{
|
||||||
char buf[256+RFC1123_TIME_LEN+1];
|
char *buf = NULL;
|
||||||
char *datestring = NULL;
|
char *datestring = NULL;
|
||||||
|
|
||||||
if (!reason_phrase) { /* bullet-proofing */
|
if (!reason_phrase) { /* bullet-proofing */
|
||||||
|
@ -3493,16 +3493,14 @@ write_http_status_line(dir_connection_t *conn, int status,
|
||||||
tor_asprintf(&datestring, "Date: %s\r\n", datebuf);
|
tor_asprintf(&datestring, "Date: %s\r\n", datebuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tor_snprintf(buf, sizeof(buf), "HTTP/1.0 %d %s\r\n%s\r\n",
|
tor_asprintf(&buf, "HTTP/1.0 %d %s\r\n%s\r\n",
|
||||||
status, reason_phrase, datestring?datestring:"") < 0) {
|
status, reason_phrase, datestring?datestring:"");
|
||||||
log_warn(LD_BUG,"status line too long.");
|
|
||||||
tor_free(datestring);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
tor_free(datestring);
|
|
||||||
|
|
||||||
log_debug(LD_DIRSERV,"Wrote status 'HTTP/1.0 %d %s'", status, reason_phrase);
|
log_debug(LD_DIRSERV,"Wrote status 'HTTP/1.0 %d %s'", status, reason_phrase);
|
||||||
connection_buf_add(buf, strlen(buf), TO_CONN(conn));
|
connection_buf_add(buf, strlen(buf), TO_CONN(conn));
|
||||||
|
|
||||||
|
tor_free(datestring);
|
||||||
|
tor_free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write the header for an HTTP/1.0 response onto <b>conn</b>-\>outbuf,
|
/** Write the header for an HTTP/1.0 response onto <b>conn</b>-\>outbuf,
|
||||||
|
|
Loading…
Add table
Reference in a new issue