bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] [PATCH 3/7] argp'fied argument parsing & tiny fixes


From: Arash Yadegarnia
Subject: Re: [bug-inetutils] [PATCH 3/7] argp'fied argument parsing & tiny fixes
Date: Sat, 30 Aug 2008 00:06:54 +0430

On Fri, 2008-08-22 at 22:31 +0300, Sergey Poznyakoff wrote: 
> Hi Arash,
> 
> Thanks for the patches.  A couple of notes:
> 
> > telnet/commands.c:
> > -static char line[256];
> > -static char saveline[256];
> > +static char line[MAX_BUF_SIZ];
> > +static char saveline[MAX_BUF_SIZ];
> [..and then..]
> > -      strcpy (saveline, line);     /* save for shell command */
> > +      strncpy (saveline, line, MAX_BUF_SIZ);       /* save for shell 
> > command */
> 
> I'd suggest changing all these to `static char *', and replacing
> strncpys with simple assignements.

Thanks for the suggestion. I'm afraid we cannot do that. because all of
these buffers are filled dynamically (eg, fgets()). and some of them are
also copy-buffers for each other. As Alfred commented, now I think they
are just fine. I guess I was getting too paranoid for evil strcpy(). :-)
Anyways, they're reverted in new patch. 
> 
> > rcp/rcp.c:
> >         * Moved 'fflag' and 'tflag' out of main ()
> > rlogind/rlogind.c
> >         * Moved 'maxchildren', 'mode' and 'port' out of main ()
> 
> These are used only inside main, so there is no reason for making them
> global.  To pass them to parse_opt, pack them into a structure and pass
> a pointer to it as the last argument of argp_parse.  Get that pointer
> from parse_opt using child_inputs (a member of struct argp_state passed as
> the third argument to parse_opt).
> 
It was my first thought, but I was thinking it may be too much headache
for just a simple argument parsing. Anyways, I've fixed them. Thanks for
the great hint.

I'm resending the commented patches.

> Regards,
> Sergey
> 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]