From: Junio C Hamano Date: Thu, 22 Sep 2005 08:52:18 GMT Subject: Re: [PATCH] Verbose git-daemon logging 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? > @@ -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?