fixes the following potential ASAN issue by retrieving device sample spec just in time.
==pulseaudio==605==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x007f940031f0
0x007f940031f0 is located 424 bytes to the right of 1480-byte region [0x007f94002a80,0x007f94003048)
[Version] 15.0.36
[Issue Type] ASAN
Change-Id: Id3d111cc4a73d026be3c31c6a4ba7a3a6f97d835
Name: pulseaudio-modules-tizen
Summary: Pulseaudio modules for Tizen
Name: pulseaudio-modules-tizen
Summary: Pulseaudio modules for Tizen
Release: 0
Group: Multimedia/Audio
License: LGPL-2.1+
Release: 0
Group: Multimedia/Audio
License: LGPL-2.1+
name = pa_tz_device_get_name(device);
vendor_id = (dbus_int32_t)pa_tz_device_get_vendor_id(device);
product_id = (dbus_int32_t)pa_tz_device_get_product_id(device);
name = pa_tz_device_get_name(device);
vendor_id = (dbus_int32_t)pa_tz_device_get_vendor_id(device);
product_id = (dbus_int32_t)pa_tz_device_get_product_id(device);
- product_id = (dbus_int32_t)pa_tz_device_get_product_id(device);
is_running = (dbus_bool_t)pa_tz_device_is_running(device);
is_running = (dbus_bool_t)pa_tz_device_is_running(device);
+ format = samplerate = channels = 0;
spec = pa_tz_device_get_sample_spec(device);
spec = pa_tz_device_get_sample_spec(device);
- format = (dbus_int32_t)spec->format;
- samplerate = (dbus_int32_t)spec->rate;
- channels = (dbus_int32_t)spec->channels;
+ if (spec) {
+ format = (dbus_int32_t)spec->format;
+ samplerate = (dbus_int32_t)spec->rate;
+ channels = (dbus_int32_t)spec->channels;
+ }
if (device_is_match_with_mask(device, mask)) {
simple_device_dump(PA_LOG_INFO, "[MATCH]", device_id, type, name, direction, state);
if (device_is_match_with_mask(device, mask)) {
simple_device_dump(PA_LOG_INFO, "[MATCH]", device_id, type, name, direction, state);
pa_sink *sink;
pa_source *source;
pa_sink *sink;
pa_source *source;
- char spec_str[PA_SAMPLE_SPEC_SNPRINT_MAX] = { 0, };
-
pa_assert(data);
if (_check_valid_device_new_data(data) < 0) {
pa_assert(data);
if (_check_valid_device_new_data(data) < 0) {
device->is_running = false;
device->specified_stream_role = pa_xstrdup("none");
device->is_running = false;
device->specified_stream_role = pa_xstrdup("none");
- if ((sink = device_get_sink(device, NULL))) {
+ if ((sink = device_get_sink(device, NULL)))
sink->device_item = device;
sink->device_item = device;
- device->sample_spec = &sink->sample_spec;
- }
- if ((source = device_get_source(device, NULL))) {
+ if ((source = device_get_source(device, NULL)))
source->device_item = device;
source->device_item = device;
- device->sample_spec = &source->sample_spec;
- }
- pa_sample_spec_snprint(spec_str, sizeof(spec_str), device->sample_spec);
-
- pa_log_info("New device: type(%s) spec(%s) id(%u) name(%s) system_id(%s) vendor_id(%04x) product_id(%04x)",
- device->type, spec_str, device->id, device->name,
- pa_strempty(device->system_id), device->vendor_id, device->product_id);
pa_idxset_put(device->list, device, NULL);
pa_idxset_put(device->list, device, NULL);
}
const pa_sample_spec* pa_tz_device_get_sample_spec(pa_tz_device *device) {
}
const pa_sample_spec* pa_tz_device_get_sample_spec(pa_tz_device *device) {
+ pa_sink *sink;
+ pa_source *source;
+ const pa_sample_spec* spec;
+ char spec_str[PA_SAMPLE_SPEC_SNPRINT_MAX] = { 0, };
+
- return device->sample_spec;
+ /* ToDo : Devices with multiple direction with multiple sample spec should be considered */
+ if ((sink = device_get_sink(device, NULL))) {
+ spec = &sink->sample_spec;
+ } else if ((source = device_get_source(device, NULL))) {
+ spec = &source->sample_spec;
+ } else {
+ pa_log_error("Failed to get sample spec!");
+ return NULL;
+ }
+
+ pa_sample_spec_snprint(spec_str, sizeof(spec_str), spec);
+ pa_log_info("sample spec for device(%p)(%s) : %s", device, device->name, spec_str);
+
+ return spec;
}
bool pa_tz_device_is_all_suspended(pa_tz_device *device) {
}
bool pa_tz_device_is_all_suspended(pa_tz_device *device) {
- /* mirrors to the corresponding sink/source sample spec */
- const pa_sample_spec *sample_spec;
-
/* Devices are contained in this list */
pa_idxset *list;
/* Devices are contained in this list */
pa_idxset *list;