Re: [PATCH] sim-auth: Avoid using dbus_message_iter_get_element_count
Hi Slava, On 11/27/2017 05:06 AM, Slava Monich wrote: It's the only thing in ofono that requires dbus 1.9.16 or later and it's not worth it. And don't leak DBusMessage on format error. --- src/sim-auth.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) Applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org https://lists.ofono.org/mailman/listinfo/ofono
Re: [PATCH 1/2] include: Add storage.h
Hi Slava, On 11/27/2017 04:31 AM, Slava Monich wrote: To expose ofono directories to dynamically loadable plugins. --- Makefile.am | 3 ++- include/storage.h | 32 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 include/storage.h Both applied, thanks. Regards, -Denis ___ ofono mailing list ofono@ofono.org https://lists.ofono.org/mailman/listinfo/ofono
[PATCH] sim-auth: Avoid using dbus_message_iter_get_element_count
It's the only thing in ofono that requires dbus 1.9.16 or later and it's not worth it. And don't leak DBusMessage on format error. --- src/sim-auth.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/sim-auth.c b/src/sim-auth.c index f9f74d4..7b65738 100644 --- a/src/sim-auth.c +++ b/src/sim-auth.c @@ -369,9 +369,7 @@ static DBusMessage *usim_gsm_authenticate(DBusConnection *conn, struct ofono_sim_auth *sa = data; DBusMessageIter iter; DBusMessageIter array; - int i; uint8_t *aid; - int rands; if (sa->pending) return __ofono_error_busy(msg); @@ -381,27 +379,22 @@ static DBusMessage *usim_gsm_authenticate(DBusConnection *conn, if (dbus_message_iter_get_arg_type() != DBUS_TYPE_ARRAY) return __ofono_error_invalid_format(msg); - rands = dbus_message_iter_get_element_count(); - - if (rands > 3 || rands < 2) - return __ofono_error_invalid_format(msg); - sa->pending = g_new0(struct auth_request, 1); - sa->pending->msg = dbus_message_ref(msg); - sa->pending->num_rands = rands; dbus_message_iter_recurse(, ); - for (i = 0; i < sa->pending->num_rands; i++) { + while (dbus_message_iter_get_arg_type() == DBUS_TYPE_ARRAY) { int nelement; DBusMessageIter in; dbus_message_iter_recurse(, ); - if (dbus_message_iter_get_arg_type() != DBUS_TYPE_BYTE) + if (dbus_message_iter_get_arg_type() != DBUS_TYPE_BYTE || + sa->pending->num_rands == SIM_AUTH_MAX_RANDS) goto format_error; - dbus_message_iter_get_fixed_array(, >pending->rands[i], + dbus_message_iter_get_fixed_array(, + >pending->rands[sa->pending->num_rands++], ); if (nelement != 16) @@ -410,12 +403,15 @@ static DBusMessage *usim_gsm_authenticate(DBusConnection *conn, dbus_message_iter_next(); } + if (sa->pending->num_rands < 2) + goto format_error; + /* * retrieve session from SIM */ aid = find_aid_by_path(sa->aid_objects, dbus_message_get_path(msg)); sa->pending->session = __ofono_sim_get_session_by_aid(sa->sim, aid); - + sa->pending->msg = dbus_message_ref(msg); sa->pending->watch_id = __ofono_sim_add_session_watch( sa->pending->session, get_session_cb, sa, NULL); -- 1.9.1 ___ ofono mailing list ofono@ofono.org https://lists.ofono.org/mailman/listinfo/ofono
[PATCH 2/2] storage: Implement ofono_config_dir and ofono_storage_dir
--- src/storage.c | 12 1 file changed, 12 insertions(+) diff --git a/src/storage.c b/src/storage.c index bde0bea..9b7bfbc 100644 --- a/src/storage.c +++ b/src/storage.c @@ -23,6 +23,8 @@ #include #endif +#include + #define _GNU_SOURCE #include #include @@ -35,6 +37,16 @@ #include "storage.h" +const char *ofono_config_dir(void) +{ + return CONFIGDIR; +} + +const char *ofono_storage_dir(void) +{ + return STORAGEDIR; +} + int create_dirs(const char *filename, const mode_t mode) { struct stat st; -- 1.9.1 ___ ofono mailing list ofono@ofono.org https://lists.ofono.org/mailman/listinfo/ofono
[PATCH 1/2] include: Add storage.h
To expose ofono directories to dynamically loadable plugins. --- Makefile.am | 3 ++- include/storage.h | 32 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 include/storage.h diff --git a/Makefile.am b/Makefile.am index 903630b..f58cc92 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \ include/private-network.h include/cdma-netreg.h \ include/cdma-provision.h include/handsfree.h \ include/handsfree-audio.h include/siri.h \ - include/netmon.h include/lte.h include/ims.h + include/netmon.h include/lte.h include/ims.h \ + include/storage.h nodist_pkginclude_HEADERS = include/version.h diff --git a/include/storage.h b/include/storage.h new file mode 100644 index 000..243eb88 --- /dev/null +++ b/include/storage.h @@ -0,0 +1,32 @@ +/* + * + * oFono - Open Telephony stack for Linux + * + * Copyright (C) 2017 Jolla Ltd. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef __OFONO_STORAGE_H +#define __OFONO_STORAGE_H + +#ifdef __cplusplus +extern "C" { +#endif + +const char *ofono_config_dir(void); +const char *ofono_storage_dir(void); + +#ifdef __cplusplus +} +#endif + +#endif /* __OFONO_STORAGE_H */ -- 1.9.1 ___ ofono mailing list ofono@ofono.org https://lists.ofono.org/mailman/listinfo/ofono