diary

Text-based journaling program
git clone https://git.in0rdr.ch/diary.git
Log | Files | Refs | README | LICENSE

commit 14e50853371ca2d904a94fbbb1768512fde5e540
parent fc0892bb98650ef8cb7344465040311f7fc6bf40
Author: Andreas Gruhler <agruhl@gmx.ch>
Date:   Sat,  4 Dec 2021 14:19:25 +0100

correct token buf size

Diffstat:
Msrc/caldav.c | 4++--
Msrc/import.c | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/caldav.c b/src/caldav.c @@ -96,10 +96,10 @@ char* read_tokenfile() { token_bytes = ftell(token_file); rewind(token_file); - token_buf = malloc(token_bytes); + token_buf = malloc(token_bytes + 1); if (token_buf != NULL) { fread(token_buf, sizeof(char), token_bytes, token_file); - token_buf[token_bytes - 1] = '\0'; + token_buf[token_bytes] = '\0'; access_token = extract_json_value(token_buf, "access_token", true); diff --git a/src/import.c b/src/import.c @@ -18,7 +18,7 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid fread(ics, 1, ics_bytes, pfile); fclose(pfile); - ics[ics_bytes] = 0; + ics[ics_bytes] = '\0'; // fprintf(stderr, "Import ICS file: %s\n", ics); int conf_ch = 0;