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

[patch] XClassHint's not copied correctly



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there.

There is a minor glitch in tag.c:applyrules(...) regarding the copying
of XClassHint data to the local prop string. The following patch fixes
this issue:

- --- patch-tag.c begins here ---
diff --git a/tag.c b/tag.c
index 8e9ceda..368a13c 100644
- --- a/tag.c
+++ b/tag.c
@@ -67,13 +67,13 @@ applyrules(Client * c, awesome_config *awesomeconf)
     XClassHint ch = { 0, 0 };
     char *prop;
 
+    XGetClassHint(c->display, c->win, &ch);
     len += a_strlen(ch.res_class) + a_strlen(ch.res_name) + a_strlen(c->name);
 
- -    prop = p_new(char, len + 1);
+    prop = p_new(char, len + 3);
 
     /* rule matching */
- -    XGetClassHint(c->display, c->win, &ch);
- -    snprintf(prop, len + 1, "%s:%s:%s",
+    snprintf(prop, len + 3, "%s:%s:%s",
              ch.res_class ? ch.res_class : "", ch.res_name ? ch.res_name : "", c->name);
     for(i = 0; i < awesomeconf->nrules; i++)
         if(regs[i].propregex && !regexec(regs[i].propregex, prop, 1, &tmp, 0))
- --- patch-tag.c ends here ---

Since ch = { 0, 0 }, a_strlen(ch.res_class) and a_strlen(ch.res_name)
are both 0 so prop is assigned just enough space for c->name. Calling
XGetClassHint before allocating the space for prop fixes this issue.

Furthermore, we need 2 more bytes in prop to store the two ':', thus
prop is len+3 bytes long.

Cheers.

\n\n
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4 (FreeBSD)
Comment: Nikos Ntarmos <ntarmos@xxxxxxxxxxxxxxx>

iD8DBQFG++elm6J1ac+VFgoRAph5AJwO0wWchhPG7bUdPrB5nbAKsVD+6gCZAZHW
v7l0+BIZz3WTEgxtxp8Y9OQ=
=guYC
-----END PGP SIGNATURE-----


-- 
To unsubscribe, send mail to awesome-unsubscribe@xxxxxxxxxxxxx