This commit is contained in:
2026-05-27 06:24:36 -07:00
parent 656b3ade80
commit 3ab01575a2
3 changed files with 13 additions and 8 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
# If set to 1, the autograder
BAD_ERROR_REPORTING_FOR_AUTOGRADER=1
#BAD_ERROR_REPORTING_FOR_AUTOGRADER=1
CC=clang
CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c23 -D_POSIX_C_SOURCE=200809L -pthread -O2
#CFLAGS+=-Og -g -fsanitize=address,undefined
CFLAGS+=-Og -g -fsanitize=address,undefined
SRCS=main.c threadpool.c util.c server.c http.c
OBJS=$(SRCS:%.c=bin/%.o)
+5 -5
View File
@@ -52,11 +52,11 @@ const char *http_header_list_search(HTTPHeaderList *list, const char *key, const
}
#define MAX_REQUEST_LENGTH 16384
#define MAX_METHOD_LENGTH 16
#define MAX_URI_LENGTH 256
#define MAX_METHOD_LENGTH 8
#define MAX_URI_LENGTH 64
#define MAX_VERSION_LENGTH 3
#define MAX_HEADER_KEY_LENGTH 2048
#define MAX_HEADER_VALUE_LENGTH 2048
#define MAX_HEADER_KEY_LENGTH 128
#define MAX_HEADER_VALUE_LENGTH 128
#define RETURN_IF_READ_ERROR(s) \
if (ferror((s))) { \
@@ -76,7 +76,7 @@ static HTTPRequestParseResult parse_method_uri_line(
#define S(s) S1(s)
int nconv = fscanf(stream,
// clang-format off
"%" S(MAX_METHOD_LENGTH) "[A-Z0-9]"
"%" S(MAX_METHOD_LENGTH) "[a-zA-Z]"
"%c"
"%" S(MAX_URI_LENGTH) "[^ \n\r]"
"%c"
+6 -1
View File
@@ -264,7 +264,6 @@ static void handle_put_request(FILE *conn, HTTPRequest *restrict req) {
if (content_length < 0) {
write_audit_log_entry(req, 400);
send_simple_response(conn, 400);
fclose(conn);
return;
}
char temp_file[] = "temp_fileXXXXXX";
@@ -286,6 +285,12 @@ static void handle_put_request(FILE *conn, HTTPRequest *restrict req) {
close(temp_fd);
unlink(temp_file);
return;
} else if (feof(conn)) {
write_audit_log_entry(req, 400);
send_simple_response(conn, 400);
close(temp_fd);
unlink(temp_file);
return;
}
content_length -= read_size;
}