elput: Fix crash whem sd_session_get_seat fails

If systemd fails to give us a valid session id, then any further calls
to get a seat from that session are going to fail. As such, check for
a valid seat return from systemd before calling any systemd functions
which require session id.

Fixes T3785

@fix

Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
This commit is contained in:
Chris Michael 2016-06-06 14:53:35 -04:00
parent b1f62061b9
commit 180e64653d
1 changed files with 4 additions and 2 deletions

View File

@ -406,7 +406,7 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
{
Elput_Manager *em;
int ret = 0;
char *s;
char *s = NULL;
em = calloc(1, sizeof(Elput_Manager));
if (!em) return EINA_FALSE;
@ -421,6 +421,8 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
goto session_err;
}
if (!em->sid) goto session_err;
ret = sd_session_get_seat(em->sid, &s);
if (ret < 0)
{
@ -428,7 +430,7 @@ _logind_connect(Elput_Manager **manager, const char *seat, unsigned int tty)
free(s);
goto seat_err;
}
else if ((seat) && (strcmp(seat, s)))
else if ((seat) && (s) && (strcmp(seat, s)))
{
ERR("Seat '%s' differs from session seat '%s'", seat, s);
free(s);