[Mesa-dev] [PATCH 1/2] util/u_debug: Pass correct size to strncat.
Brian Paul
brianp at vmware.com
Wed Apr 23 07:21:23 PDT 2014
On 04/23/2014 07:55 AM, jfonseca at vmware.com wrote:
> From: José Fonseca <jfonseca at vmware.com>
>
> Courtesy of Clang static analyzer.
> ---
> src/gallium/auxiliary/util/u_debug.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
> index fe51717..dc840e8 100644
> --- a/src/gallium/auxiliary/util/u_debug.c
> +++ b/src/gallium/auxiliary/util/u_debug.c
> @@ -334,10 +334,10 @@ debug_dump_flags(const struct debug_named_value *names,
> while(names->name) {
> if((names->value & value) == names->value) {
> if (!first)
> - util_strncat(output, "|", sizeof(output));
> + util_strncat(output, "|", sizeof(output) - strlen(output) - 1);
> else
> first = 0;
> - util_strncat(output, names->name, sizeof(output) - 1);
> + util_strncat(output, names->name, sizeof(output) - strlen(output) - 1);
> output[sizeof(output) - 1] = '\0';
> value &= ~names->value;
> }
> @@ -346,12 +346,12 @@ debug_dump_flags(const struct debug_named_value *names,
>
> if (value) {
> if (!first)
> - util_strncat(output, "|", sizeof(output));
> + util_strncat(output, "|", sizeof(output) - strlen(output) - 1);
> else
> first = 0;
>
> util_snprintf(rest, sizeof(rest), "0x%08lx", value);
> - util_strncat(output, rest, sizeof(output) - 1);
> + util_strncat(output, rest, sizeof(output) - strlen(output) - 1);
> output[sizeof(output) - 1] = '\0';
> }
>
>
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list