git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Verbose git-daemon logging

From
Junio C Hamano <junkio@cox.net>
Date
Sep 22, 2005, 08:52 UTC
Message-ID
<7vwtl9mqm5.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20050921213933.GB10575@pasky.or.cz>

Overall looks very informative to me. Couple of points, although your patch was not directly addressed to me... ;-).

> +static void logreport(const char *err, va_list params)
> +{
> +	/* We should do a single write so that it is atomic and output
> +	 * of several threads does not get intermangled. */
"threads"?  Nevertheless yes it is nicer to do a single write.
> +	char buf[1024];
> +	int buflen;
> +
> +	buflen = snprintf(buf, 1024, "[%d] ", getpid());
sizeof(buf)?
> +	buflen += vsnprintf(buf + buflen, 1024 - buflen, err, params);

vsnprintf() would return number of characters that would have been written if the buffer were sufficiently long, so buflen can grow outside buf[]. I could ask for a deeeeeeeeeeep directory to git-daemon, have it say "Request for 'diiiiiiiiiiiiii....r'", and have this code

> +	buf[buflen++] = '\n';
> +	buf[buflen] = '\0';

overwrite the stack with these two bytes; overwriting with constant bytes may or may not be exploitable, though.

Also the man page says glibc 2.0.6 returned -1 upon output truncation. Do we care?

Show 7 quoted lines
> @@ -212,6 +275,9 @@ static void child_handler(int signo)
>  			unsigned reaped = children_reaped;
>  			dead_child[reaped % MAX_CHILDREN] = pid;
>  			children_reaped = reaped + 1;
> +			/* XXX: Custom logging, since we don't wanna getpid() */
> +			if (verbose)
> +				fprintf(stderr, "[%d] Disconnected\n", pid);

"we don't wanna getpid()" because the guy reporting is the parent? I would presume knowing parent PID would also useful, so maybe we could say "[1012] child 1014 disconnected\n" for parent 1012 reaping chilid 1014?

Previous: Petr BaudisNext: Petr Baudis
Message 2 of 6 in “Verbose git-daemon logging”
  1. Verbose git-daemon loggingPetr Baudis, Sep 21, 2005
  2. Junio C HamanoSep 22, 2005
  3. Petr BaudisSep 22, 2005
  4. Junio C HamanoSep 22, 2005
  5. Linus TorvaldsSep 22, 2005
  6. Morten WelinderSep 23, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.