ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] [GIT PATCH 01/01] Possible fix for string comparison issue in set_w


From: J.R. Mauro
Subject: [RP] [GIT PATCH 01/01] Possible fix for string comparison issue in set_winname
Date: Fri, 1 Aug 2008 22:18:14 -0400
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

>From da6fc67cbee27cf3ec870f97b4596d30bebe31f2 Mon Sep 17 00:00:00 2001
From: J.R. Mauro <address@hidden>
Date: Fri, 1 Aug 2008 22:09:07 -0400
Subject: [PATCH] Possibly fixed FIXME in set_winname() in actions.c by
 adding null byte to comparison strings.

---
 src/actions.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/actions.c b/src/actions.c
index 4365679..55bc164 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -3812,13 +3812,16 @@ 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))
+  /* FIXED?: Using strncmp is sorta dirty since `title' and
+     `titlefoobar' would both match. But its quick and dirty. 
+     
+       jrm: Added a null byte to comparisons... should work?
+     */
+  if (!strncmp (name, "title\0", 6))
     defaults.win_name = WIN_NAME_TITLE;
-  else if (!strncmp (name, "name", 4))
+  else if (!strncmp (name, "name\0", 5))
     defaults.win_name = WIN_NAME_RES_NAME;
-  else if (!strncmp (name, "class", 5))
+  else if (!strncmp (name, "class\0", 6))
     defaults.win_name = WIN_NAME_RES_CLASS;
   else
     return cmdret_new (RET_FAILURE, "defwinname: invalid argument");
-- 
1.5.4.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]