Download raw body.
patch: tsort has no business handling NUL bytes
The Opengroup text says:
file
A pathname of a text file to order. If no file operand is given, the standard input shall be used.
Keyword: text
a NUL byte has no place in a text file.
Index: tsort.c
===================================================================
RCS file: /build/data/openbsd/cvs/src/usr.bin/tsort/tsort.c,v
diff -u -p -r1.39 tsort.c
--- tsort.c 23 Jun 2026 08:27:37 -0000 1.39
+++ tsort.c 24 Jun 2026 11:16:39 -0000
@@ -312,19 +312,24 @@ read_pairs(FILE *f, struct ohash *h, int
while ((str = fgetln(f, &size)) != NULL) {
char *sentinel;
+ char *s;
sentinel = str + size;
+
+ for (s = str; s < sentinel; s++)
+ if (*s == '\0')
+ errx(1, "NUL byte detected in %s", name);
+
for (;;) {
char *e;
while (str < sentinel &&
- (isspace((unsigned char)*str) || *str == '\0'))
+ (isspace((unsigned char)*str)))
str++;
if (str == sentinel)
break;
for (e = str;
- e < sentinel && !isspace((unsigned char)*e) &&
- *e != '\0'; e++)
+ e < sentinel && !isspace((unsigned char)*e); e++)
continue;
if (toggle) {
a = node_lookup(h, str, e);
patch: tsort has no business handling NUL bytes