Re: [PATCH] Fix set_work_tree on cygwin

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

 



Hi,

On Thu, 2 Aug 2007, Alex Riesen wrote:

> Johannes Schindelin, Thu, Aug 02, 2007 17:38:37 +0200:
> 
> > On Thu, 2 Aug 2007, Alex Riesen wrote:
> > 
> > >@@ -209,7 +209,8 @@ const char *set_work_tree(const char *dir)
> > >        len = strlen(dir);
> > >        if (len > postfix_len && !strcmp(dir + len - postfix_len,
> > >                                "/" DEFAULT_GIT_DIR_ENVIRONMENT)) {
> > >-                       strncpy(dir_buffer, dir, len - postfix_len);
> > >+               strncpy(dir_buffer, dir, len - postfix_len);
> > >+               dir_buffer[len - postfix_len] = '\0';
> > >
> > >                /* are we inside the default work tree? */
> > >                rel = get_relative_cwd(buffer, sizeof(buffer), dir_buffer);
> > 
> > Darn, darn, darn.  strncpy does _not_ NUL terminate.  I keep forgetting 
> > that.
> > 
> > Better use strlcpy()?
> 
> Of course, but it just should not be needed at all: static supposed to
> be zeroed.

Certainly.  But reality outweighs theory, and so I Ack either your patch 
or replacing it by strlcpy().

Ciao,
Dscho
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux