Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly improper error handling #50

Open
musteresel opened this issue Feb 4, 2021 · 0 comments
Open

Possibly improper error handling #50

musteresel opened this issue Feb 4, 2021 · 0 comments

Comments

@musteresel
Copy link

bluez-tools/src/bt-obex.c

Lines 587 to 589 in f653217

Device *device = find_device(adapter, opp_device_arg, &error);
exit_if_error(error);
dst_address = g_strdup(device_get_address(device, &error));

device here can be NULL. If it is, it causes an assertion in device_get_address to fail (so at least it crashes early):

(gdb) run -a "60:57:18:21:55:5B" -p "24:41:8C:A8:7D:5B" main.qml
Starting program: /nix/store/blrjp452yrhyy2i3yadfd60bral7ps75-bluez-tools-2016-12-12/bin/bt-obex -a "60:57:18:21:55:5B" -p "24:41:8C:A8:7D:5B" main.qml
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libthread_db.so.1".
[New Thread 0x7fffea693700 (LWP 32736)]
[New Thread 0x7fffe9e92700 (LWP 32737)]
**
ERROR:lib/bluez/device.c:265:device_get_address: assertion failed: (DEVICE_IS(self))
Bail out! ERROR:lib/bluez/device.c:265:device_get_address: assertion failed: (DEVICE_IS(self))

Thread 1 "bt-obex" received signal SIGABRT, Aborted.
0x00007ffff7aa508a in raise () from /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7aa508a in raise () from /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libc.so.6
#1  0x00007ffff7a8f528 in abort () from /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libc.so.6
#2  0x00007ffff7ec1dd3 in g_assertion_message.cold () from /nix/store/m7f15ibdd637dy3aysakk47xkqzj956l-glib-2.64.5/lib/libglib-2.0.so.0
#3  0x00007ffff7f1d61b in g_assertion_message_expr () from /nix/store/m7f15ibdd637dy3aysakk47xkqzj956l-glib-2.64.5/lib/libglib-2.0.so.0
#4  0x000000000040d1b1 in device_get_address ()
#5  0x0000000000404a18 in main ()

Not sure why device is NULL for me, but that's a different story.

Also not sure about the level of "NULL checks" in general, so feel free to ignore/close if this is "normal" and wanted behavior (the assertion at least catches it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant