Bug#121899: No wonder it segfaults
At Thu, 26 Dec 2002 18:01:10 -0500,
H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
> At least, it's not surprising that the "minimal case" Branden provided in
> BTS segfaults. It's nothing to do with getpt(); the code is using in
> uninitialized pointer *pts.
Yes. This test program is wrong. It needs to replace *pts to pts, or
allocate *pts.
> Barring that, however, I have just confirmed that on libc6 (2.3.1-3),
> getpt() does not return an error if /dev/pts is chmod'd to 0, as Branden
> suggested. I found that it was still successfully allocating a pty file
> descriptor for the pty. However, ptsname() will return a NULL pointer,
> because it won't have the permissions to read the pty.
Your analisys is right. xterm needs to fix.
> I'm not sure if this should be considered a bug, since getpt() *does*
> allocate a new pty, even if it is unreadable. I have confirmed that a new
> pty does appear in /dev/pts, and gets removed once the test program exits.
> In other words, it *does* successfully allocate a pty and returns the file
> descriptor, as described by the .info documentation.
Yup.
> Whether or not getpt() should check for the pty's readability is another
> issue, and I don't think libc is "buggy" there either --- one really
> should check the return value of ptsname() (or other pts-accessing calls),
> which *is* returning NULL in this case when it can't read the pty.
>
> At any rate, I tried this with xterm, and got:
> xterm: unable to access pty device: Permission denied
>
> I'm not sure if Branden worked around the problem in xterm, or upstream
> has fixed the problem. Perhaps this bug should be closed.
I also don't know it's already fixed, but at least I think it's not
glibc bug.
Branden, please check your latest X11, and could I close this bug?
-- gotom
Reply to: