diff options
| author | John Keeping | 2016-08-07 15:54:14 +0100 |
|---|---|---|
| committer | John Keeping | 2016-10-01 11:43:33 +0100 |
| commit | 35df710a1fa21b62c5328e2c98f29a68a0312a25 (patch) | |
| tree | db984e301d72179483d6173138f2323b02b98967 | |
| parent | 11695a58fd732689be486edf88d145578a787c89 (diff) | |
| download | cgit-35df710a1fa21b62c5328e2c98f29a68a0312a25.tar.gz cgit-35df710a1fa21b62c5328e2c98f29a68a0312a25.tar.bz2 cgit-35df710a1fa21b62c5328e2c98f29a68a0312a25.zip | |
configfile: fix EOF handling
Currently we can end up passing EOF to isspace(), which is in fact
libgit's sane_isspace which does:
((sane_ctype[(unsigned char)(x)] & (GIT_SPACE)) != 0)
It is very unlikely that EOF cast to "unsigned char" will end up in a
character that has the GIT_SPACE bit set, but the standard only requires
that EOF be a negative integer, so it could access any value in the
sane_ctype array.
If it does end up returning true for isspace() then this loop will never
terminate, so handle EOF as a special value in the same way as the other
loops in this function.
Signed-off-by: John Keeping <john@keeping.me.uk>
| -rw-r--r-- | configfile.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/configfile.c b/configfile.c index 5b0d880..e039109 100644 --- a/configfile.c +++ b/configfile.c | |||
| @@ -39,7 +39,9 @@ static int read_config_line(FILE *f, struct strbuf *name, struct strbuf *value) | |||
| 39 | 39 | ||
| 40 | /* Skip comments and preceding spaces. */ | 40 | /* Skip comments and preceding spaces. */ |
| 41 | for(;;) { | 41 | for(;;) { |
| 42 | if (c == '#' || c == ';') | 42 | if (c == EOF) |
| 43 | return 0; | ||
| 44 | else if (c == '#' || c == ';') | ||
| 43 | skip_line(f); | 45 | skip_line(f); |
| 44 | else if (!isspace(c)) | 46 | else if (!isspace(c)) |
| 45 | break; | 47 | break; |
