From 65df45923622192c3812308062049463dbfb5a01 Mon Sep 17 00:00:00 2001 From: ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ Date: Wed, 21 Sep 2022 10:58:14 +0800 Subject: Fix crash & make sure no garbage at the end --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index f4e9a40..2dee8c0 100644 --- a/main.c +++ b/main.c @@ -15,8 +15,9 @@ static char *html(const char *host) struct stat sb; fstat(fd, &sb); char template[sb.st_size + 1]; - read(fd, path, sb.st_size); + read(fd, template, sb.st_size); close(fd); + template[sb.st_size] = '\0'; const size_t html_len = sb.st_size - strlen("%s") * 4 + strlen(API_KEY) + strlen(host) + strlen(APP_URL) * 2; char *html = malloc(html_len + 1); -- cgit v1.3