[
Thread Prev][
Thread Next] >
Date Index
>
Thread Index
[wmx] patch for my dynamic config. of frame and tab colours
Zvezdan Petkovic -
Sun May 28 01:16:57 2006
I recently noticed errors in the .xsession-errors file at start of wmx
and although they are harmless I patched my previous patch to eliminate
them. There's also a fix for a potential buffer overflow due to
strncpy() property of not terminating the string if the string being
copied is longer than the specified buffer size.
Patch is sort of self-readable.
Chris, can you please commit this to CVS?
Zvezdan Petkovic
--- Config.C.orig Thu Aug 14 09:07:12 2003
+++ Config.C Fri May 26 20:02:13 2006
@@ -151,9 +151,21 @@
else if (OPTION("lower")) m_impl->rightBt = 2;
else if (OPTION("toggleheight")) m_impl->rightBt = 4;
- if (OPTION("tabfg:")) strncpy(m_impl->tabfg, s, COLOR_LEN);
- if (OPTION("tabbg:")) strncpy(m_impl->tabbg, s, COLOR_LEN);
- if (OPTION("framebg:")) strncpy(m_impl->framebg, s, COLOR_LEN);
+ if (OPTION("tabfg:")) {
+ strncpy(m_impl->tabfg, s, COLOR_LEN);
+ m_impl->tabfg[COLOR_LEN-1] = '\0'; // prevent unterminated string
+ s += strlen(m_impl->tabfg); // avoid error message below
+ }
+ if (OPTION("tabbg:")) {
+ strncpy(m_impl->tabbg, s, COLOR_LEN);
+ m_impl->tabbg[COLOR_LEN-1] = '\0';
+ s += strlen(m_impl->tabbg);
+ }
+ if (OPTION("framebg:")) {
+ strncpy(m_impl->framebg, s, COLOR_LEN);
+ m_impl->framebg[COLOR_LEN-1] = '\0';
+ s += strlen(m_impl->framebg);
+ }
if (*s != '\0') {
fprintf(stderr, "\nwmx: Dynamic configuration error: "
Next: