Re: [PATCH 8/6 v2] receive-pack: Send internal errors over side-band #2
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Feb 11, 2010, 08:34 UTC
- Message-ID
- <4B73C0FF.5020503@viscovery.net>
- In-Reply-To
- <20100210173412.GG2747@spearce.org>
Shawn O. Pearce schrieb:
Show 10 quoted lines
> +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, err, params);
> + if (sz > (sizeof(msg) - 1))
> + sz = sizeof(msg) - 1;
> + msg[sz++] = '\n';Sorry, still no joy - the terminating NUL is missing (I should have noticed this in your v1 already). I suggest to forgo the length check for simplicity because this function is only called with data that is already guaranteed to be less than 1000 bytes, i.e.:
strncpy(msg, prefix, sz); /* data is guaranteed to fit due to packet length limit in read_head_info() */ sz += vsprintf(msg + sz, err, params); msg[sz++] = '\n'; msg[sz++] = '\0';
-- Hannes