[igt-dev] [PATCH i-g-t] lib/igt_edid: Properly pad display descriptor strings
Petri Latvala
petri.latvala at intel.com
Tue Aug 10 09:26:19 UTC 2021
Display descriptor strings should be terminated with LF (when less
than 13 bytes) and padded with space. Currently the termination is
there but we're missing the padding.
As a drive-by, this fixes the below compile warning by making sure
strncpy has enough room.
[206/1103] Compiling C object lib/libigt-igt_edid_c.a.p/igt_edid.c.o
In file included from /usr/include/string.h:495,
from ../lib/igt_edid.c:29:
In function ‘strncpy’,
inlined from ‘detailed_timing_set_string’ at ../lib/igt_edid.c:186:2:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:10: warning: ‘__builtin_strncpy’ specified bound 13 equals destination size [-Wstringop-truncation]
106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Petri Latvala <petri.latvala at intel.com>
---
lib/igt_edid.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/igt_edid.c b/lib/igt_edid.c
index 6fe984d9..908959f4 100644
--- a/lib/igt_edid.c
+++ b/lib/igt_edid.c
@@ -183,7 +183,8 @@ void detailed_timing_set_string(struct detailed_timing *dt,
np->type = type;
- strncpy(ds->str, str, sizeof(ds->str));
+ memset(ds->str, ' ', sizeof(ds->str));
+ strncpy(ds->str, str, sizeof(ds->str) - 1);
len = strlen(str);
if (len < sizeof(ds->str))
ds->str[len] = '\n';
--
2.29.2
More information about the igt-dev
mailing list