aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-12-06 17:57:41 -0600
committerMatt Strapp <strap012@umn.edu>2020-12-06 17:57:41 -0600
commit9903a5eaec8e7814a960b1aea4f0246785d3f8c2 (patch)
tree7ea35f84e87d8b9736909cdfe1cefdf1f8a69eeb
parentNOT CLEAR. I AM A MORON. (diff)
downloadcsci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.tar
csci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.tar.gz
csci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.tar.bz2
csci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.tar.lz
csci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.tar.xz
csci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.tar.zst
csci4061-9903a5eaec8e7814a960b1aea4f0246785d3f8c2.zip
I AM A MORON
-rw-r--r--P4/util.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/P4/util.c b/P4/util.c
index 67e8a9b..c710af9 100644
--- a/P4/util.c
+++ b/P4/util.c
@@ -100,19 +100,23 @@ int get_request(int fd, char *filename) {
read(fd, buffer, 2048);
printf("%s\n", buffer);
- if(sscanf(buffer, "%s %s %s", get, filename, http) < 2) { // Read HTTP Get request and parse
+ if(sscanf(buffer, "%s %s %s", get, filename, http) < 2) { // Read HTTP Get request and parse
+ close(fd);
return -1;
}
else if (strcmp(get, "GET")) {
+ close(fd);
printf("Not a GET\n");
return -2;
}
else if (strlen(filename) > 1023) {
+ close(fd);
printf("Not sure but bad\n");
return -3;
}
for (int i=0; i<strlen(filename); i++) {
if ((strstr(filename, "//")) != 0 || (strstr(filename, "..")) != 0) {
+ close(fd);
printf("Invalid directory!\n");
return -4;
}
@@ -163,7 +167,7 @@ int return_result(int fd, char *content_type, char *buf, int numbytes) {
return -4;
}
if (write(fd, buf, numbytes) == -1) {
- perror("Write error");
+ perror("Bad write");
close(fd);
return -5;
}