Merge lp:~robert-ancell/lightdm/lp-1231841 into lp:lightdm

Proposed by Robert Ancell
Status: Merged
Approved by: Robert Ancell
Approved revision: 1814
Merged at revision: 1816
Proposed branch: lp:~robert-ancell/lightdm/lp-1231841
Merge into: lp:lightdm
Diff against target: 47 lines (+9/-11)
1 file modified
src/x-server-local.c (+9/-11)
To merge this branch: bzr merge lp:~robert-ancell/lightdm/lp-1231841
Reviewer Review Type Date Requested Status
Robert Ancell Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+191078@code.launchpad.net

Commit message

Fix accessing free'd string when checking for X server existence. This was introduced in rev 1651 (lightdm 1.7.0)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Robert Ancell (robert-ancell) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/x-server-local.c'
2--- src/x-server-local.c 2013-08-26 12:05:34 +0000
3+++ src/x-server-local.c 2013-10-14 23:43:28 +0000
4@@ -84,7 +84,7 @@
5 {
6 GList *link;
7 gchar *path;
8- gboolean exists;
9+ gboolean in_use;
10 gchar *data;
11
12 /* See if we know we are managing a server with that number */
13@@ -97,26 +97,24 @@
14
15 /* See if an X server that we don't know of has a lock on that number */
16 path = g_strdup_printf ("/tmp/.X%d-lock", display_number);
17- exists = g_file_test (path, G_FILE_TEST_EXISTS);
18- g_free (path);
19- if (!exists)
20- return FALSE;
21+ in_use = g_file_test (path, G_FILE_TEST_EXISTS);
22
23 /* See if that lock file is valid, ignore it if the contents are invalid or the process doesn't exist */
24- if (g_file_get_contents (path, &data, NULL, NULL))
25+ if (in_use && g_file_get_contents (path, &data, NULL, NULL))
26 {
27 int pid;
28
29 pid = atoi (g_strstrip (data));
30- if (pid <= 0)
31- return FALSE;
32+ g_free (data);
33
34 errno = 0;
35- if (kill (pid, 0) < 0 && errno == ESRCH)
36- return FALSE;
37+ if (pid < 0 || (kill (pid, 0) < 0 && errno == ESRCH))
38+ in_use = FALSE;
39 }
40+
41+ g_free (path);
42
43- return TRUE;
44+ return in_use;
45 }
46
47 guint

Subscribers

People subscribed via source and target branches