util: Ensure debug_dump_flags generates a null-terminated string.
authorVinson Lee <vlee@vmware.com>
Wed, 23 Dec 2009 23:19:45 +0000 (15:19 -0800)
committerVinson Lee <vlee@vmware.com>
Wed, 23 Dec 2009 23:19:45 +0000 (15:19 -0800)
src/gallium/auxiliary/util/u_debug.c

index 96d400c..be5eb87 100644 (file)
@@ -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)