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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 14, 2009 at 22:33, Tarmigan Casebolt <tarmigan+git@xxxxxxxxx> wrote:
> 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@xxxxxxxxxxxxxx>
> Signed-off-by: Tarmigan Casebolt <tarmigan+git@xxxxxxxxx>
> ---
>
> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]