summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-03 14:33:53 +0100
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2014-03-03 14:33:53 +0100
commit3aab77ce8a8b884d0575ba0f66398b0303936774 (patch)
tree752d5bca45aef44975da2abcc46c7a44ceb266e8
parente8669d9f3c09101b81ad1d6e01f4b3e45bc1a33c (diff)
downloadratpoison-3aab77ce8a8b884d0575ba0f66398b0303936774.zip
In set_winname compare the full string, including the final NUL.
* detects erroneous inputs such as "titlefoo" instead of "title"
-rw-r--r--src/actions.c8
1 files changed, 3 insertions, 5 deletions
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);