1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 20:38:08 +01:00

Fix workspace limit segfault

wmaker keeps the names of all workspaces together in
the string 'buf' with fixed length of 1024, therefore
allowing buffer overflows if the number of workspaces
is big enough.

For the default names "Workspace X" (from 1 to 9)
and "Workspace XX" (from 10 to 99) etc, the approximate
number of workspaces necessary to make the buffer
overflow occur is 80, because

(11*9) + (71*12) + 80 = 1031

The fix is to set the size of 'buf' as
the maximum number of workspaces times their maximum
name length.

The problem was reported by John H. Robinson in the wmaker-dev
list ( http://lists.windowmaker.info/dev/msg00214.html ):

 "http://www.youtube.com/watch?v=fkNJZvKwmhE

  Michael reported a problem with Window Maker where it crashes with a
  SIGSGV when trying to create an 82nd workspace.

  /usr/local/WindowMaker-0.92.1pre/bin/wmaker warning: Window Maker exited
  due to a crash (signal 11) and will be restarted.

  I was able to reproduce it by making 81 workspaces, then creating an 82nd."

[ crmafra: Wrote the changelog ]
This commit is contained in:
Samir SAADA
2009-04-19 23:23:46 +02:00
committed by Carlos R. Mafra
parent f21ce5768b
commit 9fa4fbef91

View File

@@ -826,7 +826,7 @@ updateCurrentWorkspace(WScreen *scr) /* changeable */
static void
updateWorkspaceNames(WScreen *scr)
{
char buf[1024], *pos;
char buf[MAX_WORKSPACES*(MAX_WORKSPACENAME_WIDTH+1)], *pos;
unsigned int i, len, curr_size;
pos = buf;