Permalink
Browse files

Fix OOB while reading bar input.

If the status bar script returns NUL as the first character through
stdin, spectrwm is prone to an out of boundary access. Depending on
the memory layout of the machine, it could turn into an OOB write.

The fix is simple: If the string is empty, do not further check for
newline character.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
  • Loading branch information...
stoeckmann authored and LordReg committed Oct 14, 2017
1 parent 1ec03c6 commit ea3e6da62247572e92c4ba00f70eab73f6254adf
Showing with 1 addition and 1 deletion.
  1. +1 −1 spectrwm.c
View
@@ -2761,7 +2761,7 @@ bar_extra_update(void)
while (fgets(b, sizeof(b), stdin) != NULL) {
if (bar_enabled) {
len = strlen(b);
if (b[len - 1] == '\n') {
if (len > 0 && b[len - 1] == '\n') {
/* Remove newline. */
b[--len] = '\0';

0 comments on commit ea3e6da

Please sign in to comment.