summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-18 15:50:27 -0500
committerJune McEnroe <june@causal.agency>2019-12-18 15:50:27 -0500
commitd39fa31782cd516dab64e8b66b2be08903f2c594 (patch)
tree31c7a1f64f418de5b3d6e607aabad0fe161235bc
parentPost "cgit setup" (diff)
downloadsrc-d39fa31782cd516dab64e8b66b2be08903f2c594.tar.gz
src-d39fa31782cd516dab64e8b66b2be08903f2c594.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.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 4cbca999..de9111a6 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));