Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Nov 2022 18:11:38 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 1a7136cf2942 - stable/13 - split: reset errno prior to getline()
Message-ID:  <202211111811.2ABIBcPC073088@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a7136cf2942ba895e3e7ce9d524afca1b1c8e08

commit 1a7136cf2942ba895e3e7ce9d524afca1b1c8e08
Author:     Math Ieu <sigsys@gmail.com>
AuthorDate: 2022-10-27 17:01:57 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-11-11 18:08:57 +0000

    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() [...]")
    (cherry picked from commit 172be8642d93851b0c083d0db240cf35fd56ab0e)
---
 usr.bin/split/split.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211111811.2ABIBcPC073088>