This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] cygcheck.cc update for cygpath()


On Mar 11 10:07, Brian Dessent wrote:
> Corinna Vinschen wrote:
> 
> > Btw., you don't need to make the buffers MAX_PATH + 1.  MAX_PATH is
> > defined including the trailing NUL.  Existing code shows a lot of
> > irritation about this...
> 
> Oh, I wasn't even thinking of that... the reason I used MAX_PATH + 1 was
> because earlier I had written
> 
> +      static char tmp[SYMLINK_MAX + 1];
> 
> so that the following sizes would not need to be SYMLINK_MAX - 1, 
> 
> +      if (!readlink (fh, tmp, SYMLINK_MAX))
> 
> +	  strncpy (tmp, cygpath (papp, NULL), SYMLINK_MAX);
> 
> +	  strncpy (lastsep+1, ptr, SYMLINK_MAX - (lastsep-tmp));
> 
> 
> I.e. pure lazyness of wanting to type the least necessary.  But now that
> you mention it, it makes more sense to have the "- 1" than the "+ 1"
> form, so I'll change that.

Urgh.  MAX_PATH is defined with trailing 0, SYMLINK_MAX is defined
without trailing 0 (like NAME_MAX).  You should better change the
SYMLINK_MAX stuff back, afaics...


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]