Closed ang-st closed 9 years ago
Please note that Ambit3 support (#54) is still a work in progress.
I was not able to reproduce this with my Suunto Ambit on an amd64
Debian jessie
machine with 921fce1. What version of the code are you using? Would you be able to test on amd64
or i386
so we can rule out architecture issues? Which of the hidapi
implementations are you using? From the information above, I would guess the hid-libusb.c
one. I've tried reproducing with both that implementation as well as the default hid-linux.c
one.
right it seems to be arch dependent, it run fine on x86
, i only had the issue on arm
.
I will investigate further in the next week as soon as i get the watch back. Thanks for pointing me that there are two implementations of hid available. I will try both. The problem occured on the latest version, I didn't try to go backward in revesion but I suspect it won't help. Thanks for your time
Hello,
i found where the bug was located, a simple missing parenthesis resulting a wrong memory allocation at libambit_sbem0102_command_request
the original code only alloc data_objects->size
thu the subsequent memcpy write out of bound and corrupt the heap.
// file src/libambit/sbem0102.c:119
send_data = malloc(sizeof(special_header) + data_objects != NULL ? data_objects->size : 0);
this way it evaluate the ternary operator and then sum it to sizeof(special_header)
send_data = malloc(sizeof(special_header) + (data_objects != NULL ? data_objects->size : 0));
then the code run fine :-)
On a side note i don't know why this work on x86
and only occur in arm
, while i don't think the extra parentethis will hurt on either platform.
Thanks!
You missed two other malloc()
statements in the same file that had the same problem but that's no problem. I'll be pushing a fix in a jiffy.
As to your side note, writing beyond allocated memory bounds results in undefined behaviour. The crashing you observed on arm
is one kind of undefined behaviour, everything going fine on x86
is another kind of undefined behaviour :sweat_smile:
Hello, i try to run openambit on raspberry pi but it actually crashes
i recompiled with -O0 and -ggdb flags and it appear to crash at some point while calling hid_read
here is the backtrace generated by the coredump
I would be glad to help you to fix this issue, as i intend to use libambit on a kind of funny project. Thanks in advance