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

Re: [PATCH] Fix git_mkstemp to return an error when path is too long.

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 26, 2007, 03:36 UTC
Message-ID
<Pine.LNX.4.64.0707260433280.14781@racer.site>
In-Reply-To
<46A7F9C4.7030004@gmail.com>
Hi,
On Thu, 26 Jul 2007, Carlos Rica wrote:
Show 7 quoted lines
> @@ -79,12 +80,14 @@ int git_mkstemp(char *path, size_t len, const char *template)
>  		pch += 5;
>  	} else {
>  		size_t n = snprintf(pch, len, "%s/", env);
> -
> +		if (n >= len)
> +			return -2;

That is certainly a bug fixed (even if few people have an insanely long TMPDIR...)

Show 7 quoted lines
>  		len -= n;
>  		pch += n;
>  	}
> 
> -	strlcpy(pch, template, len);
> +	if (strlcpy(pch, template, len) >= len)
> +		return -2;

Maybe just "return error("filename too long: %.*s", 60, pch);"? So that all callers to git_mkstemp() get the message for free?

Ciao, Dscho

Previous: Carlos RicaNext: Junio C Hamano
Message 2 of 4 in “Fix git_mkstemp to return an error when path is too long.”
  1. Fix git_mkstemp to return an error when path is too long.Carlos Rica, Jul 26, 2007
  2. Johannes SchindelinJul 26, 2007
  3. Junio C HamanoJul 26, 2007
  4. Carlos RicaJul 26, 2007

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.