Fix workspace limit segfault
commit9fa4fbef91139b3cba1f1981cb07cd2999cae48a
authorSamir SAADA <zepard@gmail.com>
Sun, 19 Apr 2009 21:23:46 +0000 (19 23:23 +0200)
committerCarlos R. Mafra <crmafra@gmail.com>
Sun, 9 Aug 2009 00:34:21 +0000 (9 02:34 +0200)
tree2d3f5529ba9d8649bf8d1919831e5790e076a69c
parentf21ce5768b2c699a46ca289626d81a5c5d11deb7
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 ]
src/wmspec.c