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

Re: [PATCH 3/4] ref-filter: merge get_obj and get_object

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jul 10, 2018, 09:19 UTC
Message-ID
<20180710091925.11061-1-szeder.dev@gmail.com>
In-Reply-To
<010201647e19c24c-fd353913-225a-4153-aa0f-6ddf41ae6354-000000@eu-west-1.amazonses.com>
Show 5 quoted lines
>  static int get_object(struct ref_array_item *ref, const struct object_id *oid,
> -		       int deref, struct object **obj, struct strbuf *err)
> +		      int deref, struct object **obj, struct strbuf *err)
>  {
>  	int eaten;

Here the variable 'eaten' is declared, but left uninitialized. This was fine until now, because ...

>  	int ret = 0;
>  	unsigned long size;
> -	void *buf = get_obj(oid, obj, &size, &eaten);
... this line used to set it anyway.
Show 12 quoted lines
> +	enum object_type type;
> +	void *buf = read_object_file(oid, &type, &size);
>  	if (!buf)
>  		ret = strbuf_addf_ret(err, -1, _("missing object %s for %s"),
>  				      oid_to_hex(oid), ref->refname);
> -	else if (!*obj)
> -		ret = strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
> -				      oid_to_hex(oid), ref->refname);
> -	else
> -		grab_values(ref->value, deref, *obj, buf, size);
> +	else {
> +		*obj = parse_object_buffer(oid, type, size, buf, &eaten);

However, with this change 'eaten' is only set here conditionally: if read_object_file() doesn't return a valid object buffer, then 'eaten' remains uninitialized.

Show 7 quoted lines
> +		if (!*obj)
> +			ret = strbuf_addf_ret(err, -1, _("parse_object_buffer failed on %s for %s"),
> +					      oid_to_hex(oid), ref->refname);
> +		else
> +			grab_values(ref->value, deref, *obj, buf, size);
> +	}
>  	if (!eaten)
And ultimately this condition could depend on an uninitialized value.
Show 6 quoted lines
>  		free(buf);
>  	return ret;
> 
> --
> https://github.com/git/git/pull/520
> 
Previous: Olga TelezhnayaNext: Johannes Schindelin
Message 3 of 10 in “ref-filter: add info_source to valid_atom”
  1. 1/4 ref-filter: add info_source to valid_atomOlga Telezhnaya, Jul 9, 2018
  2. 3/4 ref-filter: merge get_obj and get_objectOlga Telezhnaya, Jul 9, 2018
  3. SZEDER GáborJul 10, 2018
  4. Johannes SchindelinJul 10, 2018
  5. SZEDER GáborJul 10, 2018
  6. Оля ТележнаяJul 10, 2018
  7. 2/4 ref-filter: add empty values to technical fieldsOlga Telezhnaya, Jul 9, 2018
  8. Junio C HamanoJul 9, 2018
  9. Оля ТележнаяJul 10, 2018
  10. 4/4 ref-filter: use oid_object_info() to get objectOlga Telezhnaya, Jul 9, 2018

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.