NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: lib/53640: getnstr(3) shall read at most n characters, not n-1
The following reply was made to PR lib/53640; it has been noted by GNATS.
From: Valery Ushakov <uwe%stderr.spb.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc:
Subject: Re: lib/53640: getnstr(3) shall read at most n characters, not n-1
Date: Sat, 29 Sep 2018 18:29:35 +0300
On Sat, Sep 29, 2018 at 14:05:00 +0000, Kamil Rytarowski wrote:
> > On Sat, Sep 29, 2018 at 10:30:01 +0000, n54%gmx.com@localhost wrote:
> >
> > > It's documented in POSIX to reat at most N bytes; but the NetBSD
> > > curses(3) version reads at most N-1 bytes.
> > >
> > > http://pubs.opengroup.org/onlinepubs/7908799/xcurses/getnstr.html
> >
> > I don't think that definition is precise enough. It doesn't
> > explicitly say if the buffer is NUL terminated on overflow.
>
> It's specified that the input string is terminated by a \0 byte.
>
> "The resulting value is placed in the area pointed to by str. The string
> is then terminated with a null byte. "
>
> In combination of "functions read at most n bytes" I assume that I can
> enter n characters (bytes) and a string is always terminated with a NUL
> character.
Given the overall confusion that usually surrounds these kinds of "n"
functions, it would be better that this kind of details is specified
as explicitly as possible.
E.g. another wording issue to pick on - does the newline or carriage
return 1) count towards "N" and 2) are they stored?
Solaris manual page explicitly says newline IS placed into the
destination string:
These functions call wgetch(3XCURSES) and place each
received character in str until a newline is received, which
is also placed in str.
but it fact tests show that it's NOT stored.
ncurses explicitly says the newline is NOT placed into the output
buffer.
And so, between all possible permutations of what is said and what is
not and what of what is said is actually wrong there are so many
possible ways to interpret this.
As I said in my previous reply, all manual pages for this suck in one
way or another and I still think NetBSD behavior seems globally
correct (POSIX wording notwithstanding).
> > Is it really that hard to explicitly quote the results you observe
> > with these tests? I find it rather disingenuous. Can't you
> > explicitly state your point?
>
> This is an interactive program. You cannot enter N characters into it,
> only up to N-1.
*sigh* And again you are speaking in the abstract. Not about the
specific test code you quoted.
> -----BEGIN PGP SIGNATURE-----
Please, can you turn this off for gnats replies? Combined with
quoted-printable of the actual reply it clutters the bug report,
making it harder to read.
-uwe
Home |
Main Index |
Thread Index |
Old Index