From 172be8642d93851b0c083d0db240cf35fd56ab0e Mon Sep 17 00:00:00 2001 From: Math Ieu Date: Thu, 27 Oct 2022 12:01:57 -0500 Subject: split: reset errno prior to getline() Something else may have set errno, breaking the post-getline() logic that tries to detect the getline() error. This was initially noted in a jail on a system that has HPET, in a jail that does not expose /dev/hpet0 -- we see an earlier error in libc's vdso bits. Fixes: 5c053aa3c5e90 ("split: switch to getline() [...]") --- usr.bin/split/split.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.bin') diff --git a/usr.bin/split/split.c b/usr.bin/split/split.c index 008b614f4946..091c914ba8f7 100644 --- a/usr.bin/split/split.c +++ b/usr.bin/split/split.c @@ -278,7 +278,7 @@ split2(void) err(EX_NOINPUT, "fdopen"); /* Process input one line at a time */ - while ((len = getline(&buf, &bufsize, infp)) > 0) { + while ((errno = 0, len = getline(&buf, &bufsize, infp)) > 0) { /* Check if we need to start a new file */ if (pflag) { regmatch_t pmatch; -- cgit v1.2.3