Git development
 help / color / mirror / Atom feed
* minor problems in git.c
@ 2005-12-01 12:00 Robert Watson
  2005-12-01 12:48 ` Alex Riesen
  0 siblings, 1 reply; 6+ messages in thread
From: Robert Watson @ 2005-12-01 12:00 UTC (permalink / raw)
  To: git

Hi,

There are some minor problems in git.c:

(1) potential buffer overrun.

        strncat(&git_command[len], "/git-", sizeof(git_command) - len);
        len += 5;
        strncat(&git_command[len], argv[i], sizeof(git_command) - len);

The first line will write one byte ('\0') beyond the end of
git_command, when sizeof(git_command) - len == 5.

The second line increase len by 5, without regarding how many bytes
are written in the first line.  It is possible to make len greater
than sizeof(git_command), therefore make the third argument of the
third line underflow, allowing almost any number of bytes from argv[1]
to be copied.

(2) environ

int main(int argc, char **argv, char **envp)
{
  ...
  execve(git_command, &argv[i], envp);
  ...
}

I am wondering whether the global variable "environ" could change when
you do setenv.  Would it be clear by using the "environ" as the third
argument of evecve()?

(3) printf("Failed to run command '%s': %s\n", git_command, strerror(errno));
should go to stderr?

Regards,
Robertoo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-12-02  8:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-01 12:00 minor problems in git.c Robert Watson
2005-12-01 12:48 ` Alex Riesen
2005-12-01 13:51   ` Sven Verdoolaege
2005-12-01 14:02     ` Alex Riesen
2005-12-02  1:07       ` Junio C Hamano
2005-12-02  8:12         ` Alex Riesen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox