util/u_debug: Pass correct size to strncat.
authorJosé Fonseca <jfonseca@vmware.com>
Tue, 22 Apr 2014 11:32:17 +0000 (12:32 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Wed, 23 Apr 2014 18:12:23 +0000 (19:12 +0100)
Courtesy of Clang static analyzer.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/util/u_debug.c

index fe517175eb19cbe43894b4724379aee06836a2d7..dc840e8566c0b190059dba72efaf393cd64a26bc 100644 (file)
@@ -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';
    }