HomeFreeBSD

getdelim(3): Fix losing data on [EAGAIN]

Description

getdelim(3): Fix losing data on [EAGAIN]

Currently when an [EAGAIN] is encountered we return a partial result
that does not contain the delimeter. On the next (successful) read we
were returning the next part of the line without the preceding string
from the first failed call.

Fix this by using the same mechanism as ungetc(3) does. For the buffered
case we could simply set fp->_r and fp->_p back to their values before
sappend() is ran but for simplicity ungetc(3) is done in there as well.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31687

Details

Provenance
bdreweryAuthored on Aug 25 2021, 6:37 PM
Reviewer
kib
Differential Revision
D31687: getdelim(3): Fix losing data on EAGAIN
Parents
rGc7b4c21ee461: openssh: regenerate freebsd-namespace.h
Branches
Unknown
Tags
Unknown