Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 2, 2015

Conversation

alan-mushi
Copy link
Contributor

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
Copy link
Contributor

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 added a commit that referenced this pull request Feb 2, 2015
connman_ncurses crashes when No suitable services are found in a technology and the user press enter
@jobol jobol merged commit 524cb15 into eurogiciel-oss:master Feb 2, 2015
@jobol
Copy link
Contributor

jobol commented Feb 2, 2015

great, thank you to you both

@alan-mushi alan-mushi deleted the issue4 branch February 2, 2015 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants