Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 01 Sep 2019 15:23:07 -0700
From:      Cy Schubert <Cy.Schubert@cschubert.com>
To:        cem@freebsd.org
Cc:        Cy Schubert <Cy.Schubert@cschubert.com>, src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head <svn-src-head@freebsd.org>
Subject:   Re: svn commit: r351659 - in head: contrib/libc++/include  contrib/netbsd-tests/lib/libc/ssp gnu/lib/libssp include lib/libc/stdio
Message-ID:  <201909012223.x81MN7jK005967@slippy.cwsent.com>
In-Reply-To: <CAG6CVpVMN6BkATaz7qqhaVHhUpqQLrP3kSWHpMzPz2AR5GnaQw@mail.gmail.com>
References:  <201909011612.x81GC5DW097846@repo.freebsd.org>  <201909011932.x81JWYts004074@slippy.cwsent.com> <CAG6CVpVMN6BkATaz7qqhaVHhUpqQLrP3kSWHpMzPz2AR5GnaQw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message <CAG6CVpVMN6BkATaz7qqhaVHhUpqQLrP3kSWHpMzPz2AR5GnaQw@mail.gmail.c
om>
, Conrad Meyer writes:
> On Sun, Sep 1, 2019 at 12:32 PM Cy Schubert <Cy.Schubert@cschubert.com> wrote
> :
> > In message <201909011612.x81GC5DW097846@repo.freebsd.org>, Ed Maste writes:
> > > Author: emaste
> > > Date: Sun Sep  1 16:12:05 2019
> > > New Revision: 351659
> > > URL: https://svnweb.freebsd.org/changeset/base/351659
> > >
> > > Log:
> > >   libc: remove gets
> > > ...
> >
> > Should we encourage the use of gets_s() in the man page or in other doc?
>
> Hi Cy,
>
> Short version: no, we shouldn't. :-)
>
> Longer version:  Annex K functions like gets_s have zero real adoption
> (Microsoft's APIs that inspired Annex K are not actually compatible
> with the version in the standards); broadly terrible APIs; and in this
> particular case and others, unnecessarily duplicate the functionality
> of existing long-standing standard C functions (e.g., fgets(3)).

That's not quite true. From the man page:

     The gets_s() function is equivalent to fgets() with a stream of stdin,
     except that the newline character (if any) is not stored in the string.

See:

	https://en.cppreference.com/w/c/io/gets
	https://en.cppreference.com/w/c/io/fgets

Some apps may be sensitive to this subtle difference. gets_s() preserves 
this behaviour.

>
> Also, it's been a *long* time since gets(3) was known to be extremely
> broken and rejected by -D_FORTIFY_SOURCE and friends; at least twenty
> years just going by the C99 standard.  I don't think developers need
> an advisory about using alternatives to gets(3) at this point in time.

It's not an advisory to highlight the _s function. They are part of the 
standard and though we support some _s functions it would behoove us to one 
day (*) support them all.

I'm also sure some ports will probably break. Encouraging the use of 
gets_s() over fgets() due to this difference may avoid bugs in software 
that rely in the subtle difference.

* One day doesn't mean we do it tomorrow but over time is desireable.

>
> Best,
> Conrad


-- 
Cheers,
Cy Schubert <Cy.Schubert@cschubert.com>
FreeBSD UNIX:  <cy@FreeBSD.org>   Web:  http://www.FreeBSD.org

	The need of the many outweighs the greed of the few.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909012223.x81MN7jK005967>