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

Re: [PATCH] Check the format of more printf-type functions

From
Alex Riesen <raa.lkml@gmail.com>
Date
Nov 15, 2009, 14:17 UTC
Message-ID
<81b0412b0911150617x5ef81b1ao9236c49d549ef8ea@mail.gmail.com>
In-Reply-To
<1258234393-5093-1-git-send-email-tarmigan+git@gmail.com>
On Sat, Nov 14, 2009 at 22:33, Tarmigan Casebolt <tarmigan+git@gmail.com> wrote:
Show 27 quoted lines
> We already have these checks in many printf-type functions that have
> prototypes which are in header files.  Add these same checks to some
> more prototypes in header functions and to static functions in .c
> files.
>
> cc: Miklos Vajna <vmiklos@frugalware.org>
> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com>
> ---
>
> Junio, please consider this for next.  It will hopefully catch some bugs like
> the Content-Length one in http-backend.c.
>
> One extra warning is
>    CC merge-recursive.o
> merge-recursive.c: In function ‘write_tree_from_memory’:
> merge-recursive.c:218: warning: field precision should have type ‘int’, but argument 5 has type ‘size_t’
>
> A fix that might work in practice (because pathnames won't be longer than
> an int?) is:
> --- a/merge-recursive.c
> +++ b/merge-recursive.c
> @@ -215,7 +215,9 @@ struct tree *write_tree_from_memory(struct merge_options *o)
>                for (i = 0; i < active_nr; i++) {
>                        struct cache_entry *ce = active_cache[i];
>                        if (ce_stage(ce))
> -                               output(o, 0, "%d %.*s", ce_stage(ce), ce_namelen(ce), ce->name);
> +                               output(o, 0, "%d %.*s", ce_stage(ce), (int)ce_namelen(ce), ce->name);
It'll do. The message is purely diagnostics.
> +                       if (ce_namelen(ce) > INT_MAX)
> +                               die("A filename was too long");
That's overdoing it a little.
Previous: Miklos Vajna
Message 3 of 3 in “Check the format of more printf-type functions”
  1. Check the format of more printf-type functionsTarmigan Casebolt, Nov 14, 2009
  2. Miklos VajnaNov 15, 2009
  3. Alex RiesenNov 15, 2009

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.