Skip to contentSkip to conversation

adding a SDP attribute HID_DESCRIPTOR_LIST

Bluez-users Dick 2 participants 7 messages Sep 2, 2006 – Sep 5, 2006 Bluetooth drivers

lore
Share & tools
lore

Dick

author
#0 lore raw

Hi All,

I'm trying to add a SDP_ATTR_HID_DESCRIPTOR_LIST attribute to a SDP record. I've followed the (removed) "add_hid_keyb" implementation from an old sdptool.c but it segfaults!
Is there a more correct example for adding data like a descriptor list to sdp?

TIA
Dick

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#1 lore raw

Hi Dick,

Quoted 4 lines

I'm trying to add a SDP_ATTR_HID_DESCRIPTOR_LIST attribute to a SDP record. I've followed the (removed) "add_hid_keyb" implementation from an old sdptool.c but it segfaults!
Is there a more correct example for adding data like a descriptor list to sdp?

nothing has been removed from sdptool.c and the code works perfectly fine.

Regards

Marcel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

author
#2 lore raw
Quoted 2 lines · Marcel Holtmann <marcel <at> holtmann.org> writes:

nothing has been removed from sdptool.c and the code works perfectly fine.

ah now I see, add_hid_keyb isn't removed but added recently, and my bluez-utils are really outdated...

thanks for your reply!

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

author
#3 lore raw

Oh boy I've found the segfault :-)

My HID descriptor is too large to fit in SDP_SEQ_PDUFORM_SIZE ... I almost wouldn't dare to ask but ...
Could it please be increased from 128 to something larger or equal to 168?

It would also be nice to have some range checking ;-)

TIA

Dick

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#4 lore raw

Hi Dick,

Quoted 7 lines

Oh boy I've found the segfault :-)

My HID descriptor is too large to fit in SDP_SEQ_PDUFORM_SIZE ... I almost wouldn't dare to ask but ...
Could it please be increased from 128 to something larger or equal to 168?

It would also be nice to have some range checking ;-)

what are you talking about. I have no idea and it would be better if you send me an example on how to reproduce this segmentation fault.

Regards

Marcel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

author
#5 lore raw
Quoted 2 lines · Marcel Holtmann <marcel <at> holtmann.org> writes:

what are you talking about. I have no idea and it would be better if you send me an example on how to reproduce this segmentation fault.

Hi Marcel,

try the following patch on bluez-utils-3.4:

sdptool.c 2006-09-03 21:54:54.000000000 +0200 renamed from sdptool.c 2006-06-17 16:31:37.000000000 +0200 +15 -0
@@ -2139,6 +2139,21 @@
                0x75, 0x01,
                0x95, 0x04,
                0x81, 0x01,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
                0xc0         // end tag
        };
 

(this patch adds 30 zero's to hid_report so it is >128)

and see:

$ sdptool add keyb
Segmentation fault

the following patch on bluez-utils:

$ sed -i -e 's/\(#define SDP_SEQ_PDUFORM_SIZE\) 128/\1 256/' ${S}/src/sdp.c

fixes the problem for me... (increasing the PDUFORM_SIZE)

So my questions are:
- could you increase the SDP_SEQ_PDUFORM_SIZE
- it would be nice to have some range checking, it's very confusing because the segfault occures in sdp_record_register and not in sdp_attr_add()/sdp_data_alloc()/sdp_seql_alloc()

greetings,
Dick

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#6 lore raw

Hi Dick,

Quoted 28 lines
Quoted 2 lines

what are you talking about. I have no idea and it would be better if you send me an example on how to reproduce this segmentation fault.

try the following patch on bluez-utils-3.4:

sdptool.c 2006-09-03 21:54:54.000000000 +0200 renamed from sdptool.c 2006-06-17 16:31:37.000000000 +0200 +15 -0
@@ -2139,6 +2139,21 @@
                0x75, 0x01,
                0x95, 0x04,
                0x81, 0x01,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
+               0x0, 0x0,
                0xc0         // end tag
        };
 
Quoted 1 line

(this patch adds 30 zero's to hid_report so it is >128)

the used buffer is from the stack and we end up overwriting the stack.

Quoted 11 lines

and see:

$ sdptool add keyb
Segmentation fault

the following patch on bluez-utils:

$ sed -i -e 's/\(#define SDP_SEQ_PDUFORM_SIZE\) 128/\1 256/' ${S}/src/sdp.c

fixes the problem for me... (increasing the PDUFORM_SIZE)

So my questions are:
- could you increase the SDP_SEQ_PDUFORM_SIZE

I removed the constant completely and increased the buffer to 256 byte for now.

Quoted 3 lines

- it would be nice to have some range checking, it's very confusing because the segfault occures in sdp_record_register and not in sdp_attr_add()/sdp_data_alloc()/sdp_seql_alloc()

The problem is actually in sdp_append_to_pdu() and this needs fixing. Feel free to propose a patch. And it would be better to not use stack memory for this.

Regards

Marcel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users