commit 6a9f2e7ea33f75cab2e95fe03204813222b01e9c
parent 4abd78c2ac6e5fe2a2060b265233cdb000dd0b93
Author: Andreas Gruhler <agruhl@gmx.ch>
Date: Sun, 28 Nov 2021 23:22:34 +0100
fix(token_bytes): invalid write of size 1
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/caldav.c b/src/caldav.c
@@ -93,13 +93,13 @@ char* read_tokenfile() {
}
fseek(token_file, 0, SEEK_END);
- token_bytes = ftell(token_file) + 1;
+ token_bytes = ftell(token_file);
rewind(token_file);
token_buf = malloc(token_bytes);
if (token_buf != NULL) {
fread(token_buf, sizeof(char), token_bytes, token_file);
- token_buf[token_bytes] = '\0';
+ token_buf[token_bytes - 1] = '\0';
access_token = extract_json_value(token_buf, "access_token", true);