From: Shawn O. Pearce Date: Wed, 10 Feb 2010 17:17:08 GMT Subject: Re: [PATCH 8/6] receive-pack: Send internal errors over side-band #2 Message-ID: <20100210171708.GF2747@spearce.org> In-Reply-To: <4B725CB1.1080908@viscovery.net> Johannes Sixt wrote: > Shawn O. Pearce schrieb: > > +static void rp_error(const char *err, ...) __attribute__((format (printf, 1, 2))); > > +static void rp_warning(const char *err, ...) __attribute__((format (printf, 1, 2))); > > + > > +static void report_message(const char *prefix, const char *err, va_list params) > > +{ > > + int sz = strlen(prefix); > > + char msg[4096]; > > + > > + strncpy(msg, prefix, sz); > > + sz += vsnprintf(msg + sz, sizeof(msg) - (sz + 1), err, params); > > + msg[sz++] = '\n'; > > This writes beyond the buffer if it is too small because the return value > tells how many characters *would* have been written if it were > sufficiently large, no? Ugh. I don't code C often enough anymore. Thank you for catching that. > > +static void rp_warning(const char *err, ...) > > ... > > +static void rp_error(const char *err, ...) > > ... > > Looks like we need set_report_routine(). > > Or did you replace only selected error() and warning() calls by rp_error() > and rp_warning()? As described by others in the thread... I only replaced selected calls. Well, most of them, maybe too many. But I didn't want to expose everything to the client. So I added new functions. Yes, it was painful. I wasn't happy about it. But I also wasn't happy about exposing every message to the client over the side-band channel. -- Shawn.