xwayland: fix lock file parsing
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Mon, 14 Nov 2016 13:05:28 +0000 (15:05 +0200)
committerDaniel Stone <daniels@collabora.com>
Wed, 16 Nov 2016 16:24:15 +0000 (16:24 +0000)
commit61beda653b85c5b9bfb2f2fbf120ac7ab5a3fde9
tree40100355b98c4d141855cf4560c97b3c7713aa85
parent9b1f8ef7bcafeee19d8537f34a95cf0f3c112ccc
xwayland: fix lock file parsing

Patch 139fcabe7cdb1f2296bf02ef917aaab84e00cd4e "xwayland: Improve error
checking for strtol call" caused a regression in the X11 unix socket
lock file parsing. Before that patch, only the first 10 characters were
considered for parsing. After the patch, the newline as the 11th
character caused strtol() to stop parsing at the 10th character which
was then considered an error as not the whole input was consumed.

The effect of the regression was that no X11 lock files were ever deemed
stale, hence stale lock files were never removed. Up till now, I have
accumulated 37 lock files, and Weston complaining for each of them on
every start it cannot parse them.

Fix this by terminating the string at the expected newline character.

Also, it looks like 'pid' was being used uninitialized, risking strtol()
reading past the end of the array. This patch fixes that too.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
xwayland/launcher.c