This is the mail archive of the
mailing list for the glibc project.
Re: [PING][PATCH v2] Remove check for NULL buffer passed to `ptsname_r'
- From: Arjun Shankar <arjun dot is at lostca dot se>
- To: Zack Weinberg <zackw at panix dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Joseph Myers <joseph at codesourcery dot com>, Florian Weimer <fweimer at redhat dot com>
- Date: Wed, 7 Jun 2017 14:09:56 +0000
- Subject: Re: [PING][PATCH v2] Remove check for NULL buffer passed to `ptsname_r'
- Authentication-results: sourceware.org; auth=none
- References: <20170607115039.GB65837@aloka.lostca.se> <CAKCAbMiO4iy9_jLFKbWfKumo8=VpQTkg1hr2noM06g1DDcBtqg@mail.gmail.com>
On Wed, Jun 07, 2017 at 09:39:40AM -0400, Zack Weinberg wrote:
> > `ptsname_r' is declared in stdlib.h to only accept a `nonnull'
> > second argument and therefore GCC may choose to make optimizations
> > based on the assumption that this argument is NULL. This means
> > that potentially, GCC can optimize away the NULL check at some
> > point in the future. Since this is a programming interface, we
> > might as well remove the NULL check ourselves.
> > This also warrants a change to the `ptsname_r' manual page that
> > must be submitted to the corresponding mailing list.
> Is this function documented in our manual (manual/*.texi)? If so,
> please update that.
The function is documented, but there is no reference to EINVAL and no
hint that a NULL buf is handled in any way. Here is the relevant text
(source is in manual/terminal.texi):
> -- Function: int ptsname_r (int FILEDES, char *BUF, size_t LEN)
> Preliminary: | MT-Safe | AS-Unsafe heap/bsd | AC-Unsafe mem fd |
> *Note POSIX Safety Concepts::.
> The ptsname_r function is similar to the ptsname function
> except that it places its result into the user-specified buffer
> starting at BUF with length LEN.
> This function is a GNU extension.
Given this, I propose that we leave the this section unchanged. Instead, I
will propose a change to the man-pages project where `man ptsname_r'
documents this (now unhandled) error condition:
> EINVAL (ptsname_r() only) buf is NULL.
...once I commit this change.
Does the above sound like a reasonable course of action?
> OK with that change. I don't think we need a copyright assignment for
> a change that deletes seven lines of code and adds none.
Even otherwise, I have an assignment on file, and I recently got commit
access in git :)