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
=== modified file 'src/x-server-local.c'
--- src/x-server-local.c 2013-08-26 12:05:34 +0000
+++ src/x-server-local.c 2013-10-14 23:43:28 +0000
@@ -84,7 +84,7 @@
84{84{
85 GList *link;85 GList *link;
86 gchar *path;86 gchar *path;
87 gboolean exists;87 gboolean in_use;
88 gchar *data;88 gchar *data;
8989
90 /* See if we know we are managing a server with that number */90 /* See if we know we are managing a server with that number */
@@ -97,26 +97,24 @@
9797
98 /* See if an X server that we don't know of has a lock on that number */98 /* See if an X server that we don't know of has a lock on that number */
99 path = g_strdup_printf ("/tmp/.X%d-lock", display_number);99 path = g_strdup_printf ("/tmp/.X%d-lock", display_number);
100 exists = g_file_test (path, G_FILE_TEST_EXISTS);100 in_use = g_file_test (path, G_FILE_TEST_EXISTS);
101 g_free (path);
102 if (!exists)
103 return FALSE;
104101
105 /* See if that lock file is valid, ignore it if the contents are invalid or the process doesn't exist */102 /* See if that lock file is valid, ignore it if the contents are invalid or the process doesn't exist */
106 if (g_file_get_contents (path, &data, NULL, NULL))103 if (in_use && g_file_get_contents (path, &data, NULL, NULL))
107 {104 {
108 int pid;105 int pid;
109106
110 pid = atoi (g_strstrip (data));107 pid = atoi (g_strstrip (data));
111 if (pid <= 0)108 g_free (data);
112 return FALSE;
113109
114 errno = 0;110 errno = 0;
115 if (kill (pid, 0) < 0 && errno == ESRCH)111 if (pid < 0 || (kill (pid, 0) < 0 && errno == ESRCH))
116 return FALSE;112 in_use = FALSE;
117 }113 }
114
115 g_free (path);
118 116
119 return TRUE;117 return in_use;
120}118}
121119
122guint120guint

Subscribers

People subscribed via source and target branches