xlsatoms -format "%s" sounds like a good idea, the resulting crash isn't. I'm too lazy to check for all possible combinations that we allow here (it is a printf-compatible string), so let's just check that we have two specifiers %.
X.Org Bug 39614 <http://bugs.freedesktop.org/show_bug.cgi?id=39614> Signed-off-by: Peter Hutterer <[email protected]> --- This isn't meant as a security fix, just as a mere sanity fix for a simple-to-detect case. xlsatoms.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xlsatoms.c b/xlsatoms.c index eb4e21d..f21fadd 100644 --- a/xlsatoms.c +++ b/xlsatoms.c @@ -196,6 +196,20 @@ say_batch(xcb_connection_t *c, const char *format, xcb_get_atom_name_cookie_t *c char atom_name[1024]; long i; int done = 0; + int format_specifiers = 0; + + i = 0; + + while(i < strlen(format) - 1) { + if (format[i] == '%' && format[++i] != '%') + format_specifiers++; + i++; + } + + if (format_specifiers != 2) { + fprintf(stderr, "Invalid format specifier: '%s'. Need %%d and %%s.\n", format); + return 1; + } for (i = 0; i < count; i++) cookie[i] = xcb_get_atom_name(c, i + low); -- 1.8.2.1 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
