From 65df45923622192c3812308062049463dbfb5a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= 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.2.3