Download raw body.
[PATCH] fix getdelim() EOF behavior
On Thu, Oct 09, 2025 at 04:25:21PM -0400, enh wrote: > corresponds to glibc bug > https://sourceware.org/bugzilla/show_bug.cgi?id=28038... > > basically just "make sure you've terminated the buffer _before_ returning". I recall seeing getline() return a non-terminated string at some point. But at the time I couldn't reproduce this issue and then forgot about it. This diff explains what I saw, because getline() is implemented as return getdelim(buf, buflen, '\n', fp); ok stsp@ if someone else wants to commit this. > diff --git a/lib/libc/stdio/getdelim.c b/lib/libc/stdio/getdelim.c > index d709a3d18e1..292920e79c9 100644 > --- a/lib/libc/stdio/getdelim.c > +++ b/lib/libc/stdio/getdelim.c > @@ -119,13 +119,11 @@ getdelim(char **__restrict buf, size_t *__restrict buflen, > > FUNLOCKFILE(fp); > > - /* POSIX demands we return -1 on EOF. */ > - if (off == 0) > - return -1; > - > if (*buf != NULL) > *(*buf + off) = '\0'; > - return off; > + > + /* POSIX demands we return -1 on EOF. */ > + return (off == 0) ? -1 : off; > > error: > fp->_flags |= __SERR; > >
[PATCH] fix getdelim() EOF behavior