diff options
author | June McEnroe <june@causal.agency> | 2019-12-18 15:50:27 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-12-18 15:50:27 -0500 |
commit | db4429471393297d46bb81492b2a480ca2c7ac4c (patch) | |
tree | e461b76b9a2aa82a4bc361301b981d06866c0c13 | |
parent | Post "cgit setup" (diff) | |
download | src-db4429471393297d46bb81492b2a480ca2c7ac4c.tar.gz src-db4429471393297d46bb81492b2a480ca2c7ac4c.zip |
Bail from hi if input is binary
NULs in the input cause an infinite loop in htmlEscape, not to mention regexes obviously not working, etc.
Diffstat (limited to '')
-rw-r--r-- | bin/hi.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/bin/hi.c b/bin/hi.c index c8533e55..4021d1bc 100644 --- a/bin/hi.c +++ b/bin/hi.c @@ -739,6 +739,7 @@ int main(int argc, char *argv[]) { if (!str) err(EX_OSERR, "realloc"); } if (ferror(file)) err(EX_IOERR, "fread"); + if (memchr(str, 0, len)) errx(EX_DATAERR, "input is binary"); str[len] = '\0'; enum Class *hi = calloc(len, sizeof(*hi)); |