Avoid use of atoi in some places in libc

Joseph Myers joseph@codesourcery.com
Thu Dec 15 23:57:38 GMT 2022


On Thu, 15 Dec 2022, Noah Goldstein via Libc-alpha wrote:

> > diff --git a/inet/rexec.c b/inet/rexec.c
> > index 064e979d68..c647b7ac34 100644
> > --- a/inet/rexec.c
> > +++ b/inet/rexec.c
> > @@ -134,7 +134,7 @@ retry:
> >                 if (!getnameinfo(&sa2.sa, sa2len,
> >                                  NULL, 0, servbuff, sizeof(servbuff),
> >                                  NI_NUMERICSERV))
> > -                       port = atoi(servbuff);
> > +                       port = strtol(servbuff, NULL, 10);
> >                 (void) sprintf(num, "%u", port);
> Is this needed at all? Can we just copy `servbuff` to `num`?
> Or is this to handle overflow inputs to `servbuff`?

I have no idea.  rexec is highly obsolescent.  The point of these changes 
is to avoid localplt failures at minimum risk, not to optimize random 
obscure and obsolescent code.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Libc-alpha mailing list