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

Re: input validation in receive-pack

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Jan 2, 2008, 15:53 UTC
Message-ID
<alpine.LNX.1.00.0801021043220.13593@iabervon.org>
In-Reply-To
<7vhchw3hkz.fsf@gitster.siamese.dyndns.org>
On Tue, 1 Jan 2008, Junio C Hamano wrote:
Show 12 quoted lines
> @@ -816,9 +821,13 @@ struct ref_lock *lock_ref_sha1(const char *ref, const unsigned char *old_sha1)
>  
>  struct ref_lock *lock_any_ref_for_update(const char *ref, const unsigned char *old_sha1, int flags)
>  {
> -	if (check_ref_format(ref) == -1)
> +	switch (check_ref_format(ref)) {
> +	case CHECK_REF_FORMAT_ERROR:
> +	case CHECK_REF_FORMAT_WILDCARD:
>  		return NULL;
> -	return lock_ref_sha1_basic(ref, old_sha1, flags, NULL);
> +	default:
> +		return lock_ref_sha1_basic(ref, old_sha1, flags, NULL);

It might be wise to make "default" the return NULL case, and list the two okay cases explicitly, so it doesn't need to be changed if check_ref_format() someday gets additional "okay for some purposes" values.

Aside from that, it looks good, except that builtin-send-pack.c and fast-import.c should probably use the symbolic constants, too. (All other callers only check whether the value is true or not).

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 8 in “input validation in receive-pack”
  1. Martin KoeglerJan 1, 2008
  2. Junio C HamanoJan 2, 2008
  3. Daniel BarkalowJan 2, 2008
  4. Junio C HamanoJan 2, 2008
  5. Daniel BarkalowJan 2, 2008
  6. Junio C HamanoJan 2, 2008
  7. Martin KoeglerJan 2, 2008
  8. Junio C HamanoJan 2, 2008

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.