fix: HTTP header truncation

master
Sean McBride 2 years ago
parent 1230e0bfd9
commit 89fc0b26fd

@ -33,41 +33,31 @@
#define HTTP_RESPONSE_404_NOT_FOUND \ #define HTTP_RESPONSE_404_NOT_FOUND \
"HTTP/1.1 404 Not Found\r\n" \ "HTTP/1.1 404 Not Found\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Content-Length: 0\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n" \
"\r\n" \
"\r\n" "\r\n"
#define HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE \ #define HTTP_RESPONSE_413_PAYLOAD_TOO_LARGE \
"HTTP/1.1 413 Payload Too Large\r\n" \ "HTTP/1.1 413 Payload Too Large\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Content-Length: 0\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n" \
"\r\n" \
"\r\n" "\r\n"
#define HTTP_RESPONSE_429_TOO_MANY_REQUESTS \ #define HTTP_RESPONSE_429_TOO_MANY_REQUESTS \
"HTTP/1.1 429 Too Many Requests\r\n" \ "HTTP/1.1 429 Too Many Requests\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Content-Length: 0\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n" \
"\r\n" \
"\r\n" "\r\n"
#define HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR \ #define HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR \
"HTTP/1.1 500 Internal Server Error\r\n" \ "HTTP/1.1 500 Internal Server Error\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Content-Length: 0\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n" \
"\r\n" \
"\r\n" "\r\n"
#define HTTP_RESPONSE_503_SERVICE_UNAVAILABLE \ #define HTTP_RESPONSE_503_SERVICE_UNAVAILABLE \
"HTTP/1.1 503 Service Unavailable\r\n" \ "HTTP/1.1 503 Service Unavailable\r\n" \
"Server: SLEdge\r\n" \ "Server: SLEdge\r\n" \
"Content-Length: 0\r\n" \
"Connection: close\r\n" \ "Connection: close\r\n" \
"\r\n" \
"\r\n" "\r\n"
static inline const char * static inline const char *

@ -194,7 +194,7 @@ http_session_set_response_header(struct http_session *session, int status_code,
? HTTP_SESSION_RESPONSE_HEADER_CAPACITY ? HTTP_SESSION_RESPONSE_HEADER_CAPACITY
: header_len; : header_len;
strncpy(session->response_header, http_header_build(status_code), to_copy - 1); strncpy(session->response_header, http_header_build(status_code), to_copy);
session->response_header_length = to_copy; session->response_header_length = to_copy;
} }

Loading…
Cancel
Save