bluez5: better error/malformed input handling

Safer parsing of AT commands, additional null and error checks.
This commit is contained in:
Pauli Virtanen 2021-03-27 13:55:01 +02:00 committed by Wim Taymans
parent f0a2b6d01f
commit f330446291
5 changed files with 56 additions and 21 deletions

View file

@ -724,8 +724,11 @@ static DBusHandlerResult hsphfpd_new_audio_connection(DBusConnection *conn, DBus
fail:
if (r) {
dbus_connection_send(backend->conn, r, NULL);
dbus_message_unref(r);
DBusHandlerResult res = DBUS_HANDLER_RESULT_HANDLED;
if (!dbus_connection_send(backend->conn, r, NULL))
res = DBUS_HANDLER_RESULT_NEED_MEMORY;
dbus_message_unref(r);
return res;
}
return DBUS_HANDLER_RESULT_HANDLED;
@ -1069,6 +1072,11 @@ static DBusHandlerResult hsphfpd_parse_endpoint_properties(struct impl *backend,
if (!endpoint->valid && endpoint->local_address && endpoint->remote_address && endpoint->profile && endpoint->role)
endpoint->valid = true;
if (!endpoint->remote_address || !endpoint->local_address) {
spa_log_debug(backend->log, NAME": Missing addresses for %s", endpoint->path);
return DBUS_HANDLER_RESULT_HANDLED;
}
d = spa_bt_device_find_by_address(backend->monitor, endpoint->remote_address, endpoint->local_address);
if (!d) {
spa_log_debug(backend->log, NAME": No device for %s", endpoint->path);