From 3aab77ce8a8b884d0575ba0f66398b0303936774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Mon, 3 Mar 2014 14:33:53 +0100 Subject: In set_winname compare the full string, including the final NUL. * detects erroneous inputs such as "titlefoo" instead of "title" --- src/actions.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/actions.c b/src/actions.c index 49a89d9..3b2692e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -4020,13 +4020,11 @@ set_winname (struct cmdarg **args) name = ARG_STRING(0); - /* FIXME: Using strncmp is sorta dirty since `title' and - `titlefoobar' would both match. But its quick and dirty. */ - if (!strncmp (name, "title", 5)) + if (!strncmp (name, "title", sizeof ("title"))) defaults.win_name = WIN_NAME_TITLE; - else if (!strncmp (name, "name", 4)) + else if (!strncmp (name, "name", sizeof ("name"))) defaults.win_name = WIN_NAME_RES_NAME; - else if (!strncmp (name, "class", 5)) + else if (!strncmp (name, "class", sizeof ("class"))) defaults.win_name = WIN_NAME_RES_CLASS; else return cmdret_new (RET_FAILURE, "set winname: invalid argument `%s'", name); -- cgit v1.2.3