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

Re: [PATCH v2 6/6] submodule--helper: introduce new update-module-mode helper

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Jul 17, 2018, 07:59 UTC
Message-ID
<20180717075959.30594-1-szeder.dev@gmail.com>
In-Reply-To
<20180717002654.120375-7-sbeller@google.com>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 034ba1bb2e0..d4cb7c72e33 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
Show 19 quoted lines
> +static int module_update_module_mode(int argc, const char **argv, const char *prefix)
> +{
> +	const char *path, *update = NULL;
> +	int just_cloned;
> +	struct submodule_update_strategy update_strategy = { .type = SM_UPDATE_CHECKOUT };
> +
> +	if (argc < 3 || argc > 4)
> +		die("submodule--helper update-module-clone expects <just-cloned> <path> [<update>]");
> +
> +	just_cloned = git_config_int("just_cloned", argv[1]);
> +	path = argv[2];
> +
> +	if (argc == 4)
> +		update = argv[3];
> +
> +	determine_submodule_update_strategy(the_repository,
> +					    just_cloned, path, update,
> +					    &update_strategy);
> +	fprintf(stdout, submodule_strategy_to_string(&update_strategy));

Various compilers warn about the potential insecurity of the above call:

      CC builtin/submodule--helper.o
  builtin/submodule--helper.c: In function ‘module_update_module_mode’:
  builtin/submodule--helper.c:1502:2: error: format not a string literal and no format arguments [-Werror=format-security]
    fprintf(stdout, submodule_strategy_to_string(&update_strategy));
    ^
  cc1: all warnings being treated as errors
  Makefile:2261: recipe for target 'builtin/submodule--helper.o' failed
  make: *** [builtin/submodule--helper.o] Error 1
I think it should either use an explicit format string:
  fprintf(stdout, "%s", submodule_strategy_to_string(&update_strategy));
or, perhaps better yet, simply use fputs().
> +
> +	return 0;
> +}
Previous: Stefan BellerNext: Junio C Hamano
Message 8 of 20 in “git-submodule.sh: convert part of cmd_update to C”
  1. 0/6 git-submodule.sh: convert part of cmd_update to CStefan Beller, Jul 17, 2018
  2. 1/6 git-submodule.sh: align error reporting for update mode to use pathStefan Beller, Jul 17, 2018
  3. 2/6 git-submodule.sh: rename unused variablesStefan Beller, Jul 17, 2018
  4. 3/6 builtin/submodule--helper: factor out submodule updatingStefan Beller, Jul 17, 2018
  5. 4/6 builtin/submodule--helper: store update_clone information in a structStefan Beller, Jul 17, 2018
  6. 5/6 builtin/submodule--helper: factor out method to update a single submoduleStefan Beller, Jul 17, 2018
  7. 6/6 submodule--helper: introduce new update-module-mode helperStefan Beller, Jul 17, 2018
  8. SZEDER GáborJul 17, 2018
  9. Junio C HamanoJul 17, 2018
  10. Junio C HamanoJul 17, 2018
  11. Stefan BellerJul 17, 2018
  12. Eric SunshineJul 17, 2018
  13. Stefan BellerJul 18, 2018
  14. Eric SunshineJul 18, 2018
  15. Junio C HamanoJul 18, 2018
  16. Junio C HamanoJul 17, 2018
  17. Stefan BellerJul 17, 2018
  18. Junio C HamanoJul 17, 2018
  19. Johannes SchindelinJul 26, 2018
  20. Stefan BellerJul 26, 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.