Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#616 lxsession-logout - dbus-interface.c - Wrong logic condition

open
nobody
lxsession (36)
5
2014-04-21
2013-10-20
mello73
No

Tool: lxsession-logout
File: dbus-interface.c

Line: 192 (function systemd_query)

===============

if (g_variant_is_of_type (result, G_VARIANT_TYPE ("(s)")))
{
g_variant_get (result, "(s)", &str);
if (g_strcmp0 (str, "yes") || g_strcmp0 (str, "challenge")) <------- "g_strcmp0" return "0" if strings are equal !!!!
function_result = TRUE;
else
function_result = default_result;
}

g_variant_unref (result);
return function_result;
===============

If result is "no" g_strcmp0 return "-1" as per documentation function and conditial if is satisfied.

____________
g_strcmp0 ()

int g_strcmp0 (const char *str1, const char *str2);

Compares str1 and str2 like strcmp(). Handles NULL gracefully by sorting it before non-NULL strings. Comparing two NULL pointers returns 0.

str1 :
a C string or NULL

str2 :
another C string or NULL

Returns :
-1, 0 or 1, if str1 is <, == or > than str2.

Since 2.16
_______________

Correct Line 192 is:

WRONG
if (g_strcmp0 (str, "yes") || g_strcmp0 (str, "challenge"))

RIGHT:
if ( g_strcmp0 (str, "yes") == 0 || g_strcmp0 (str, "challenge") == 0 )

Discussion

  • Vedran Rodic
    Vedran Rodic
    2014-04-21

    Has this bug been fixed?

    What are the symptoms of the bug?