In message <CAG6CVpVMN6BkATaz7qqhaVHhUpqQLrP3kSWHpMzPz2AR5GnaQw@mail.gmail.c om> , Conrad Meyer writes: > On Sun, Sep 1, 2019 at 12:32 PM Cy Schubert <cy.schub...@cschubert.com> wrote > : > > In message <201909011612.x81gc5dw097...@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.schub...@cschubert.com> FreeBSD UNIX: <c...@freebsd.org> Web: http://www.FreeBSD.org The need of the many outweighs the greed of the few. _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"