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

Bug #1242456 reported by mello73
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxsession (Ubuntu)
Fix Committed
Undecided
Unassigned

Bug Description

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 )

Revision history for this message
Dave Kokandy (drkokandy) wrote :

According to this thread - http://sourceforge.net/p/lxde/bugs/616/

This fix was committed to the git repo in November 2014.

Changed in lxsession (Ubuntu):
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.