Revert to simpler fix, avoid changing behavior of socket_buffer_readline

This commit is contained in:
dmiller 2026-07-31 20:57:23 +00:00
parent ff9a53c8b0
commit 18b3db3d67

View file

@ -117,7 +117,6 @@ char *socket_buffer_readline(struct socket_buffer *buf, size_t *n, size_t maxlen
char *line;
char *newline;
size_t count;
const char *p;
line = NULL;
*n = 0;
@ -151,17 +150,6 @@ char *socket_buffer_readline(struct socket_buffer *buf, size_t *n, size_t maxlen
*n += count;
return NULL;
}
/* Check for disallowed characters */
p = buf->p + count - 2;
if (p >= buf->p && *p == '\r')
--p;
while (p >= buf->p) {
if (is_ctl_char(*p) && *p != '\t') {
free(line);
return NULL;
}
--p;
}
line = (char *) safe_realloc(line, *n + count + 1);
memcpy(line + *n, buf->p, count);
@ -992,9 +980,14 @@ int http_parse_header(struct http_header **result, const char *header)
/* Replace LWS with a single space. */
strbuf_append_str(&node->value, &value_len, &value_offset, " ");
}
q = strpbrk(p, " \t\r\n");
if (!q)
q = p + strlen(p);
q = p;
while (*q != '\0' && !is_space_char(*q) && !is_crlf(q)) {
if (is_ctl_char(*q)) {
http_header_node_free(node);
return 400;
}
q++;
}
strbuf_append(&node->value, &value_len, &value_offset, p, q - p);
p = skip_lws(q);
}