summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2024-04-30 12:01:46 -0700
committerLucas De Marchi <lucas.demarchi@intel.com>2024-05-01 01:48:55 -0500
commit25c9b91a7116a82f881c3f3125b13884c6c05625 (patch)
treeb25bcfc5823f3db8701b2f12328d7500ec4f46ba
parentd8df4b52c09637eea8dc124c77621535986f321b (diff)
lib/igt_drm_fdinfo: Assert pdev is not truncated
Since strncpy() may truncate the output, just assert we have enough room for the string. It's not a big problem since we always copy 1 byte less than the capacity and info->pdev is zero-allocated. But we may as well be sure we aren't truncating it. Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Link: https://lore.kernel.org/r/20240430190150.3654507-2-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
-rw-r--r--lib/igt_drm_fdinfo.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/igt_drm_fdinfo.c b/lib/igt_drm_fdinfo.c
index a1f4ad10d..bc3082d42 100644
--- a/lib/igt_drm_fdinfo.c
+++ b/lib/igt_drm_fdinfo.c
@@ -237,6 +237,7 @@ __igt_parse_drm_fdinfo(int dir, const char *fd, struct drm_client_fdinfo *info,
good++;
} else if ((v = find_kv(l, "drm-pdev", strlen("drm-pdev")))) {
/* optional */
+ assert(strlen(v) < sizeof(info->pdev));
strncpy(info->pdev, v, sizeof(info->pdev) - 1);
} else if (!strncmp(l, "drm-engine-capacity-", 20)) {
idx = parse_engine(l, info,