eurogiciel-oss / connman-json-client

A ncurses UI for connman
GNU General Public License v2.0
31 stars 13 forks source link

connman_ncurses crashes when No suitable services are found in a technology and the user press enter #4

Closed javier-lopez closed 9 years ago

javier-lopez commented 9 years ago

Hi, I've just keep playing with connman_curses and I found the following:

Testcase:

  1. Press enter in an ethernet interface unplugged (this also works in a wifi interface when no AP are available. connman_curses display No suitable services found for this technology
  2. Press enter. connman_curses crashes with a segmentation fault error.

The backtrace display the following:

0x000000000040d004 in exec_action (data=0x0) at main.c:427                                                                         │
427             context.serv->dbus_name = strdup(data->dbus_name);                                                 │
(gdb) backtrace                                                                                                                    │
#0  0x000000000040d004 in exec_action (data=0x0) at main.c:427                                                                     │
#1  0x000000000040f341 in exec_action_context_services (ch=10) at main.c:1401                                                      │
#2  0x000000000040f5eb in ncurses_action () at main.c:1499                                                                         │
#3  0x0000000000406df0 in loop_run (poll_stdin=true) at loop.c:199                                                                 │
#4  0x000000000040f7b5 in main () at main.c:1554
frame 1
#1  0x000000000040f341 in exec_action_context_services (ch=10) at main.c:1401
1401                exec_action(item_userptr(item));
(gdb) p item
$2 = (ITEM *) 0x0

I think the problem may be than item is defined as a null pointer (such term exist?) at that menu. If I edit the code as follows:

//main.c:1401
                        if (item != NULL) {
                exec_action(item_userptr(item));
                        }

It doesn't crash anymore but just prints a [INFO] Connecting... below.

alan-mushi commented 9 years ago

Hi, thanks for reporting, I never considered this (I'll look for some kind of monkey input tests for ncurses). It's indeed the problem (NULL pointer do exist). There is a slightly better solution: if item is NULL then we break out of the switch, this way we ignore the keystroke and "Connecting..." is never displayed. I'm doing the pull request.

jobol commented 9 years ago

great, thank you to you both