From: Vinson Lee Date: Wed, 23 Dec 2009 23:19:45 +0000 (-0800) Subject: util: Ensure debug_dump_flags generates a null-terminated string. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=51dcea2aac08ed68b713de0a741c782d51a5b916;p=mesa.git util: Ensure debug_dump_flags generates a null-terminated string. --- diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 96d400c839b..be5eb87e474 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -452,7 +452,8 @@ debug_dump_flags(const struct debug_named_value *names, util_strncat(output, "|", sizeof(output)); else first = 0; - util_strncat(output, names->name, sizeof(output)); + util_strncat(output, names->name, sizeof(output) - 1); + output[sizeof(output) - 1] = '\0'; value &= ~names->value; } ++names; @@ -465,7 +466,8 @@ debug_dump_flags(const struct debug_named_value *names, first = 0; util_snprintf(rest, sizeof(rest), "0x%08lx", value); - util_strncat(output, rest, sizeof(output)); + util_strncat(output, rest, sizeof(output) - 1); + output[sizeof(output) - 1] = '\0'; } if(first)