Re: Q about one change in patch 20260411

Thomas Dickey <[email protected]> Mon, 27 Apr 2026 03:38:16 -0400
Newsgroups gmane.comp.lib.ncurses.bugs
Message-ID <[email protected]>
On Mon, Apr 27, 2026 at 09:12:26AM +0200, Dr. Werner Fink wrote:
> Hi,
> 
> I have a report that in ncurses/tty/lib_twait.c around line 286 there
> is Off-by-one Buffer Error:
> 
> 
> ```
> for (c = 0; c < count; c++)
>     if (fds[count].revents & POLLNVAL) {
              ^^^^^ (should be 'c')
>         errno = EBADF;
>     } else if (fds[c].fd == ev->data.fev.fd
>                && fds[c].revents & POLLIN) {
>         // ...
>     }
> ```
> 
> even if this report is not valid it would help the readers to move
> the fds[count] before the loop.

yes... I'm puzzled that the test is actually succeeding (setting errno
to EBADF when it "should" -- but changing the variable does work, too)

-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net
signature.asc (application/pgp-signature, 659 B)
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEGYgtkt2kxADCLA1WzCr0RyFnvgMFAmnvEmgACgkQzCr0RyFn
vgO3Ngv/TfsU9vp3TxaDUE5wgnveL+3yHLH6GDuX3lJOcrsOqMdHh9lEK/16otrH
YfyswPT1V6JSqsuOxeRSC6iser4ZPrih172u9be8AgNlLIhqV0VBairpD7XSYxVd
bNPPhpKN3Vint4+N7LRrBZh6ClrClV1Xx6VrZLhJJwYUirF0FHo8gViD8dQ98ULv
r+Bc8Oi7edbA+n1d6KepilAIec6KoVnswVQpN9TSIW0AR72GK7h4gziP/DNnnwU5
aY2Z6l/Cc8/AvMnNPWSy8kMRAR3RE3a7+DUTOKnhJW4Om/8DT3w88InALiXhCWYu
hVJ0zBHsxEdySX/enhUItnJvg16XWxVtneriUex1RXKa8Ft4fOBf1/AL1XDL0Xaa
cvuDobV8/cns0RukSfXti2kR4+Xjt3Kd/vm2qen5iTFbLgVzcqU9aZuJIu9q9pno
Y6r+NZY51hU7nwcgRM05elVjwF5sUlSDoZCEkH9Z3j9aYRK1yfZBlYZ0CMnPfwcV
pFp6dVUM
=DV1i
-----END PGP SIGNATURE-----