all repos — cgit @ 011f2e9bdddcbfe65da397629bca87d167313a28

a hyperfast web frontend for git written in c

truncate buffer before reading empty files

If readfile() reads an empty file, fgets() won't truncate the buffer
and it'll still contain the contents of the previously read file.

[lh: fixed similar issue in ui-repolist.c]

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Simon Arlott simon@fire.lp0.eu
Sat, 07 Mar 2009 00:06:24 +0000
commit

011f2e9bdddcbfe65da397629bca87d167313a28

parent

6421dc38db02eff8d3ada93e87a2f7e5292af131

2 files changed, 2 insertions(+), 0 deletions(-)

jump to
M scan-tree.cscan-tree.c

@@ -42,6 +42,7 @@ static char buf[MAX_PATH];

if (!(f = fopen(path, "r"))) return NULL; + buf[0] = 0; fgets(buf, MAX_PATH, f); fclose(f); return buf;
M ui-repolist.cui-repolist.c

@@ -23,6 +23,7 @@ static char buf[64], buf2[64];

if (!(f = fopen(path, "r"))) return -1; + buf[0] = 0; if (fgets(buf, sizeof(buf), f) == NULL) return -1; fclose(f);