Hello Martin,

* Martin Schulze <[EMAIL PROTECTED]> [2005-05-13 09:58]:
> Nico Golde wrote:
> > Package: screen
> > Version: 4.0.2-4.1
> > Severity: wishlist
> > Tags: patch
> > Hi,
> > screen isn't able to handle ~/ if you want to load a
> > configuration file via source in the command line.
> > I hate this because it is short and good :)
> > However, I attached a patch which fixes this.
> > Please include it.
> 
> Please don't.
> 
> At least not literally.
> 
> > +  char *tmp_file, *tmp_rcname;
> >    if (rc_recursion > 10)
> >      {
> >        Msg(0, "%s: source: recursion limit reached", rc_name);
> >        return;
> >      }
> >    rc_recursion++;
> > -  FinishRc(rcfilename);
> > +  if (rcfilename[0]=='~' && rcfilename[1]=='/')
> > +  {
> > +    tmp_file=getenv("HOME");
> 
> getenv() can return NULL
> 
> Better use something like "if ((tmp_file=getenv("HOME")) != NULL) {"

I thought about this too and thought that this would be ok,
because screen uses getenv too without checking this.
anyway, i will rework it.

> > +    strncat(tmp_file,"/",1);
> 
> Ouch!  Never concat *anything* to a forignly allocated string!
> Never ever!
> 
> Create a new variable of the proper size (i.e. strlen(tmp_file)+2)
> and use that.

Thanks.

> > +    tmp_rcname=strtok(rcfilename,"~/");
> 
> Again, strtok() can return NULL.

Yes, tmp_rcname = rcfilename + 2 would be better.
Thanks!

> > +    strncat(tmp_file,tmp_rcname, strlen(tmp_rcname));
> 
> Ouch!  See my comment above.

I will send a new version in the next days.
Regards Nico
-- 
Nico Golde - [EMAIL PROTECTED] | GPG: 1024D/73647CFF
http://www.ngolde.de | http://www.muttng.org | http://grml.org 
VIM has two modes - the one in which it beeps 
and the one in which it doesn't -- encrypted mail preferred

Attachment: pgpMQSrlxZPEi.pgp
Description: PGP signature

Reply via email to