From d2013a6337972c62a71f01324e87af0e55579245 Mon Sep 17 00:00:00 2001 From: Aaron Burrow Date: Mon, 16 Jul 2018 22:46:09 +0200 Subject: [PATCH] Fix one byte NULL stack overflow Don't append a forward slash if the length of a folder is PATH_MAX-1. This can happen if HEADER_MAX is larger than PATH_MAX or if the `-m` option is used to increase the path length. --- LICENSE | 1 + http.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 3e402a5..fc7b4e0 100644 --- a/LICENSE +++ b/LICENSE @@ -9,6 +9,7 @@ Copyright 2017-2018 Hiltjo Posthuma Copyright 2017-2018 Quentin Rameau Copyright 2018 Josuah Demangeon Copyright 2018 Dominik Schmidt +Copyright 2018 Aaron Burrow Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/http.c b/http.c index f0b84b1..7a801a5 100644 --- a/http.c +++ b/http.c @@ -430,7 +430,7 @@ http_send_response(int fd, struct request *r) if (S_ISDIR(st.st_mode)) { /* add / to target if not present */ len = strlen(realtarget); - if (len == PATH_MAX - 2) { + if (len >= PATH_MAX - 2) { return http_send_status(fd, S_REQUEST_TOO_LARGE); } if (len && realtarget[len - 1] != '/') {