xwayland: fix lock file parsing

Patch 139fcabe7c "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>
dev
Pekka Paalanen 8 years ago committed by Daniel Stone
parent 9b1f8ef7bc
commit 61beda653b
  1. 3
      xwayland/launcher.c

@ -166,6 +166,9 @@ create_lockfile(int display, char *lockfile, size_t lsize)
return -1; return -1;
} }
/* Trim the newline, ensure terminated string. */
pid[10] = '\0';
if (!safe_strtoint(pid, &other)) { if (!safe_strtoint(pid, &other)) {
weston_log("can't parse lock file %s\n", weston_log("can't parse lock file %s\n",
lockfile); lockfile);

Loading…
Cancel
Save