All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] confusion about libs/sdp.c - sdp_service_search_req()
@ 2005-02-25 19:24 Albert Huang
  2005-02-28  8:34 ` Marcel Holtmann
  0 siblings, 1 reply; 5+ messages in thread
From: Albert Huang @ 2005-02-25 19:24 UTC (permalink / raw)
  To: BlueZ Mailing List

the documentation for sdp_service_search_req() states that it outputs
an sdp_list_t * of sdp_record_t * (list of sdp service records)

reading through the code, it appears that it actually returns a list
of uint32_t * data structures.

line 2721:
        extract_record_handle_seq(pdata, rsp, rec_count, &scanned);


line 2523:
static void extract_record_handle_seq(char *pdu, sdp_list_t **seq, int
count, int *scanned)
{
    sdp_list_t *pSeq = *seq;
    char *pdata = pdu;
    int n;
 
    for (n = 0; n < count; n++) {
        uint32_t *pSvcRec = (uint32_t *) malloc(sizeof(uint32_t));
        *pSvcRec = ntohl(bt_get_unaligned((uint32_t *) pdata));
        pSeq = sdp_list_append(pSeq, pSvcRec);
        pdata += sizeof(uint32_t);
        *scanned += sizeof(uint32_t);
    }
    *seq = pSeq;
}

I think this will cause segfaults when you try to sdp_record_free the
records in the list (it does for me).

perhaps it shold read something more like:
        sdp_record_t *pSvcRec = (sdp_record_t*) malloc(sizeof(sdp_record_t));
        pSvcRec->attrlist = pSvcRec->pattern = 0;
        pSvcRec->handle = ntohl(bt_get_unaligned((uint32_t *) pdata));
        pSeq = sdp_list_append(pSeq, pSvcRec);

Regards,
-albert


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-03-02 10:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-25 19:24 [Bluez-devel] confusion about libs/sdp.c - sdp_service_search_req() Albert Huang
2005-02-28  8:34 ` Marcel Holtmann
2005-02-28 12:20   ` Stephen Crane
2005-03-02  8:48     ` Albert Huang
2005-03-02 10:23       ` Stephen Crane

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.