Stuff
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
# If set to 1, the autograder
|
# If set to 1, the autograder
|
||||||
BAD_ERROR_REPORTING_FOR_AUTOGRADER=1
|
#BAD_ERROR_REPORTING_FOR_AUTOGRADER=1
|
||||||
|
|
||||||
CC=clang
|
CC=clang
|
||||||
CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c23 -D_POSIX_C_SOURCE=200809L -pthread -O2
|
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
|
SRCS=main.c threadpool.c util.c server.c http.c
|
||||||
|
|
||||||
OBJS=$(SRCS:%.c=bin/%.o)
|
OBJS=$(SRCS:%.c=bin/%.o)
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ const char *http_header_list_search(HTTPHeaderList *list, const char *key, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_REQUEST_LENGTH 16384
|
#define MAX_REQUEST_LENGTH 16384
|
||||||
#define MAX_METHOD_LENGTH 16
|
#define MAX_METHOD_LENGTH 8
|
||||||
#define MAX_URI_LENGTH 256
|
#define MAX_URI_LENGTH 64
|
||||||
#define MAX_VERSION_LENGTH 3
|
#define MAX_VERSION_LENGTH 3
|
||||||
#define MAX_HEADER_KEY_LENGTH 2048
|
#define MAX_HEADER_KEY_LENGTH 128
|
||||||
#define MAX_HEADER_VALUE_LENGTH 2048
|
#define MAX_HEADER_VALUE_LENGTH 128
|
||||||
|
|
||||||
#define RETURN_IF_READ_ERROR(s) \
|
#define RETURN_IF_READ_ERROR(s) \
|
||||||
if (ferror((s))) { \
|
if (ferror((s))) { \
|
||||||
@@ -76,7 +76,7 @@ static HTTPRequestParseResult parse_method_uri_line(
|
|||||||
#define S(s) S1(s)
|
#define S(s) S1(s)
|
||||||
int nconv = fscanf(stream,
|
int nconv = fscanf(stream,
|
||||||
// clang-format off
|
// clang-format off
|
||||||
"%" S(MAX_METHOD_LENGTH) "[A-Z0-9]"
|
"%" S(MAX_METHOD_LENGTH) "[a-zA-Z]"
|
||||||
"%c"
|
"%c"
|
||||||
"%" S(MAX_URI_LENGTH) "[^ \n\r]"
|
"%" S(MAX_URI_LENGTH) "[^ \n\r]"
|
||||||
"%c"
|
"%c"
|
||||||
|
|||||||
@@ -264,7 +264,6 @@ static void handle_put_request(FILE *conn, HTTPRequest *restrict req) {
|
|||||||
if (content_length < 0) {
|
if (content_length < 0) {
|
||||||
write_audit_log_entry(req, 400);
|
write_audit_log_entry(req, 400);
|
||||||
send_simple_response(conn, 400);
|
send_simple_response(conn, 400);
|
||||||
fclose(conn);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char temp_file[] = "temp_fileXXXXXX";
|
char temp_file[] = "temp_fileXXXXXX";
|
||||||
@@ -286,6 +285,12 @@ static void handle_put_request(FILE *conn, HTTPRequest *restrict req) {
|
|||||||
close(temp_fd);
|
close(temp_fd);
|
||||||
unlink(temp_file);
|
unlink(temp_file);
|
||||||
return;
|
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;
|
content_length -= read_size;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user