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

Re: [PATCH 8/6] receive-pack: Send internal errors over side-band #2

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 10, 2010, 17:17 UTC
Message-ID
<20100210171708.GF2747@spearce.org>
In-Reply-To
<4B725CB1.1080908@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> wrote:
Show 16 quoted lines
> 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.
 
Show 9 quoted lines
> > +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.
Previous: Johannes Sixt
Message 10 of 10 in “t5401: Use a bare repository for the remote peer”
  1. 7/6 t5401: Use a bare repository for the remote peerShawn O. Pearce, Feb 10, 2010
  2. 8/6 receive-pack: Send internal errors over side-band #2Shawn O. Pearce, Feb 10, 2010
  3. Johannes SixtFeb 10, 2010
  4. Junio C HamanoFeb 10, 2010
  5. Johannes SixtFeb 10, 2010
  6. 8/6 receive-pack: Send internal errors over side-band #2Shawn O. Pearce, Feb 10, 2010
  7. Johannes SixtFeb 11, 2010
  8. Shawn O. PearceFeb 11, 2010
  9. Johannes SixtFeb 11, 2010
  10. Shawn O. PearceFeb 10, 2010

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.