Skip to content

Commit

Permalink
Merge branch 'mer1576_get_config_crash' into 'master'
Browse files Browse the repository at this point in the history
Handle missing mode setting gracefully



See merge request !10
  • Loading branch information
Matti Kosola committed May 4, 2016
2 parents 953d302 + 1aadb95 commit 3c58dc4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/usb_moded-config.c
Expand Up @@ -310,21 +310,21 @@ static char * get_kcmdline_string(const char *entry)
{
if(!strcmp(entry, NETWORK_IP_KEY))
{
ret = g_strdup(network_tokens[0]);
g_free(ret), ret = g_strdup(network_tokens[0]);
log_debug("Command line ip = %s\n", ret);
}
if(!strcmp(entry, NETWORK_GATEWAY_KEY))
{
/* gateway might be empty, so we do not want to return an empty string */
if(strlen(network_tokens[2]) > 2)
{
ret = g_strdup(network_tokens[2]);
g_free(ret), ret = g_strdup(network_tokens[2]);
log_debug("Command line gateway = %s\n", ret);
}
}
if(!strcmp(entry, NETWORK_NETMASK_KEY))
{
ret = g_strdup(network_tokens[3]);
g_free(ret), ret = g_strdup(network_tokens[3]);
log_debug("Command line netmask = %s\n", ret);
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/usb_moded-dbus.c
Expand Up @@ -304,9 +304,16 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
{
char *config = get_mode_setting();

if(!config)
{
/* Config is corrupted or we do not have a mode
* configured, fallback to undefined. */
config = g_strdup(MODE_UNDEFINED);
}

if((reply = dbus_message_new_method_return(msg)))
dbus_message_append_args (reply, DBUS_TYPE_STRING, &config, DBUS_TYPE_INVALID);
free(config);
g_free(config);
}
else if(!strcmp(member, USB_MODE_LIST))
{
Expand Down

0 comments on commit 3c58dc4

Please sign in to comment.