microsoft/compiler: Fix incorrect size passed to strncpy
authorJesse Natalie <jenatali@microsoft.com>
Mon, 28 Dec 2020 18:44:08 +0000 (10:44 -0800)
committerMarge Bot <eric+marge@anholt.net>
Sun, 3 Jan 2021 23:07:21 +0000 (23:07 +0000)
GCC correctly detects/warns that this was the wrong size

Fixes: b9c61379 ("microsoft/compiler: translate nir to dxil")

Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8248>

src/microsoft/compiler/dxil_signature.c

index 9cd94b9..e44b16e 100644 (file)
@@ -163,7 +163,7 @@ get_semantic_sv_name(nir_variable *var, struct semantic_info *info)
    default:
       unreachable("unsupported system value");
    }
-   strncpy(info->name, var->name, 64);
+   strncpy(info->name, var->name, ARRAY_SIZE(info->name) - 1);
 }
 
 static void