summaryrefslogtreecommitdiff
path: root/userland/httpd/httpd.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-10-14 16:37:18 +0200
committerAnton Kling <anton@kling.gg>2024-10-14 16:37:18 +0200
commit3fd4be7cb2744d852cf99e627f7bfea3fd83bd3c (patch)
tree0d2e2a9d5b85aaf631e551ba88be0930e715c711 /userland/httpd/httpd.c
parent3011c0589b8ab7cbfed127ce45a04f154441b406 (diff)
libc: Copy string views to preallocated buffers
Diffstat (limited to 'userland/httpd/httpd.c')
-rw-r--r--userland/httpd/httpd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/userland/httpd/httpd.c b/userland/httpd/httpd.c
index 845355a..aeae6aa 100644
--- a/userland/httpd/httpd.c
+++ b/userland/httpd/httpd.c
@@ -107,9 +107,11 @@ void parse_incoming_request(struct http_request *request) {
return;
}
- char *p = SV_TO_C(path);
- request->file_fd = open(p, O_RDONLY);
- free(p);
+ {
+ char path_buffer[256];
+ sv_to_cstring_buffer(path, path_buffer, 256);
+ request->file_fd = open(path_buffer, O_RDONLY);
+ }
if (-1 == request->file_fd) {
request->status_code = 404;
return;