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

Re: [Patch size_t V3 17/19] Convert ref-filter to size_t

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 17, 2017, 18:03 UTC
Message-ID
<xmqqmv6ygjha.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1502914591-26215-18-git-send-email-martin@mail.zuhause>
Martin Koegler <martin.koegler@chello.at> writes:
Show 5 quoted lines
> -static char *copy_subject(const char *buf, unsigned long len)
> +static char *copy_subject(const char *buf, size_t len)
>  {
>  	char *r = xmemdupz(buf, len);
>  	int i;

This has the same "we are still iterating with 'int i' over an array that can be 'size_t len' long" issue as I pointed out in 19/19. The remedy is similar, i.e.

	static char *copy_subject(const char *buf, size_t len)
	{
		char *ret = xmemdupz(buf, len);
		char *cp;
		for (cp = ret; cp < ret + len; cp++)
			if (*cp == '\n')
				*cp = ' ';
		return ret;
	}

which should come either before the whole series or after the series settles, not inside this series.

I do also wonder if we want to do more for other control characters (e.g. CR, HT, etc.) in this function, though. That is totally outside the scope of this series and should be done independently.

Show 9 quoted lines
> @@ -898,7 +898,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
>  }
>  
>  /* See grab_values */
> -static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, unsigned long sz)
> +static void grab_person(const char *who, struct atom_value *val, int deref, struct object *obj, void *buf, size_t sz)
>  {
>  	int i;
>  	int wholen = strlen(who);
Shouldn't this also become size_t, I wonder?

I did not see anything fishy in the remaining parts I did not comment on.

Thanks.
Previous: Martin KoeglerNext: Junio C Hamano
Message 13 of 33 in “use size_t”
  1. 00/19 use size_tMartin Koegler, Aug 16, 2017
  2. 03/19 Convert zlib.c to size_tMartin Koegler, Aug 16, 2017
  3. 01/19 delta: fix enconding size larger than an "uint" can holdMartin Koegler, Aug 16, 2017
  4. Torsten BögershausenAug 17, 2017
  5. 08/19 Convert fsck.c & commit.c to size_tMartin Koegler, Aug 16, 2017
  6. 11/19 Use size_t for config parsingMartin Koegler, Aug 16, 2017
  7. Johannes SixtAug 24, 2017
  8. 04/19 delta: Fix offset overflowsMartin Koegler, Aug 16, 2017
  9. 12/19 Convert pack-objects to size_tMartin Koegler, Aug 16, 2017
  10. 19/19 Convert xdiff-interface to size_tMartin Koegler, Aug 16, 2017
  11. Junio C HamanoAug 17, 2017
  12. 17/19 Convert ref-filter to size_tMartin Koegler, Aug 16, 2017
  13. Junio C HamanoAug 17, 2017
  14. Junio C HamanoAug 17, 2017
  15. 10/19 Add overflow check to get_delta_hdr_sizeMartin Koegler, Aug 16, 2017
  16. 18/19 Convert tree-walk to size_tMartin Koegler, Aug 16, 2017
  17. Junio C HamanoAug 17, 2017
  18. 16/19 Convert various things to size_tMartin Koegler, Aug 16, 2017
  19. Junio C HamanoAug 21, 2017
  20. 15/19 Convert archive functions to size_tMartin Koegler, Aug 16, 2017
  21. Junio C HamanoAug 21, 2017
  22. brian m. carlsonAug 22, 2017
  23. 07/19 Convert parse_X_buffer to size_tMartin Koegler, Aug 16, 2017
  24. 14/19 Convert unpack-objects to size_tMartin Koegler, Aug 16, 2017
  25. 13/19 Convert index-pack to size_tMartin Koegler, Aug 16, 2017
  26. Ramsay JonesAug 16, 2017
  27. 02/19 Convert size datatype to size_tMartin Koegler, Aug 16, 2017
  28. 09/19 Convert cache functions to size_tMartin Koegler, Aug 16, 2017
  29. 05/19 Convert sha1_file.c to size_tMartin Koegler, Aug 16, 2017
  30. 06/19 Use size_t for sha1Martin Koegler, Aug 16, 2017
  31. Junio C HamanoAug 16, 2017
  32. Torsten BögershausenAug 17, 2017
  33. Martin KoeglerAug 18, 2017

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.