diff options
| -rw-r--r-- | common/glib-helper.c | 4 | ||||
| -rw-r--r-- | include/sdp_lib.h | 12 | ||||
| -rw-r--r-- | lib/sdp.c | 52 | ||||
| -rw-r--r-- | src/adapter.c | 4 | ||||
| -rw-r--r-- | src/sdpd-request.c | 4 | ||||
| -rw-r--r-- | src/sdpd-service.c | 4 | ||||
| -rw-r--r-- | src/storage.c | 4 | 
7 files changed, 26 insertions, 58 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c index f0435aca..33fde08d 100644 --- a/common/glib-helper.c +++ b/common/glib-helper.c @@ -124,7 +124,7 @@ static void search_completed_cb(uint8_t type, uint16_t status,  		goto done;  	} -	scanned = sdp_extract_seqtype_safe(rsp, bytesleft, &dataType, &seqlen); +	scanned = sdp_extract_seqtype(rsp, bytesleft, &dataType, &seqlen);  	if (!scanned || !seqlen)  		goto done; @@ -135,7 +135,7 @@ static void search_completed_cb(uint8_t type, uint16_t status,  		int recsize;  		recsize = 0; -		rec = sdp_extract_pdu_safe(rsp, bytesleft, &recsize); +		rec = sdp_extract_pdu(rsp, bytesleft, &recsize);  		if (!rec)  			break; diff --git a/include/sdp_lib.h b/include/sdp_lib.h index 143056f6..f1f74f98 100644 --- a/include/sdp_lib.h +++ b/include/sdp_lib.h @@ -478,8 +478,7 @@ void sdp_uuid16_to_uuid128(uuid_t *uuid128, uuid_t *uuid16);  void sdp_uuid32_to_uuid128(uuid_t *uuid128, uuid_t *uuid32);  int sdp_uuid128_to_uuid(uuid_t *uuid);  int sdp_uuid_to_proto(uuid_t *uuid); -int sdp_uuid_extract(const uint8_t *buffer, uuid_t *uuid, int *scanned); -int sdp_uuid_extract_safe(const uint8_t *buffer, int bufsize, uuid_t *uuid, int *scanned); +int sdp_uuid_extract(const uint8_t *buffer, int bufsize, uuid_t *uuid, int *scanned);  void sdp_uuid_print(const uuid_t *uuid);  #define MAX_LEN_UUID_STR 37 @@ -585,8 +584,7 @@ static inline int sdp_get_icon_url(const sdp_record_t *rec, char *str, int len)  	return sdp_get_string_attr(rec, SDP_ATTR_ICON_URL, str, len);  } -sdp_record_t *sdp_extract_pdu(const uint8_t *pdata, int *scanned); -sdp_record_t *sdp_extract_pdu_safe(const uint8_t *pdata, int bufsize, int *scanned); +sdp_record_t *sdp_extract_pdu(const uint8_t *pdata, int bufsize, int *scanned);  void sdp_data_print(sdp_data_t *data);  void sdp_print_service_attr(sdp_list_t *alist); @@ -601,11 +599,9 @@ void sdp_append_to_buf(sdp_buf_t *dst, uint8_t *data, uint32_t len);  int sdp_gen_pdu(sdp_buf_t *pdu, sdp_data_t *data);  int sdp_gen_record_pdu(const sdp_record_t *rec, sdp_buf_t *pdu); -int sdp_extract_seqtype(const uint8_t *buf, uint8_t *dtdp, int *seqlen); -int sdp_extract_seqtype_safe(const uint8_t *buf, int bufsize, uint8_t *dtdp, int *size); +int sdp_extract_seqtype(const uint8_t *buf, int bufsize, uint8_t *dtdp, int *size); -sdp_data_t *sdp_extract_attr(const uint8_t *pdata, int *extractedLength, sdp_record_t *rec); -sdp_data_t *sdp_extract_attr_safe(const uint8_t *pdata, int bufsize, int *extractedLength, sdp_record_t *rec); +sdp_data_t *sdp_extract_attr(const uint8_t *pdata, int bufsize, int *extractedLength, sdp_record_t *rec);  void sdp_pattern_add_uuid(sdp_record_t *rec, uuid_t *uuid);  void sdp_pattern_add_uuidseq(sdp_record_t *rec, sdp_list_t *seq); @@ -904,7 +904,7 @@ void sdp_data_free(sdp_data_t *d)  	free(d);  } -int sdp_uuid_extract_safe(const uint8_t *p, int bufsize, uuid_t *uuid, int *scanned) +int sdp_uuid_extract(const uint8_t *p, int bufsize, uuid_t *uuid, int *scanned)  {  	uint8_t type; @@ -950,13 +950,6 @@ int sdp_uuid_extract_safe(const uint8_t *p, int bufsize, uuid_t *uuid, int *scan  	return 0;  } -int sdp_uuid_extract(const uint8_t *p, uuid_t *uuid, int *scanned) -{ -	/* Assume p points to a buffer of size at least SDP_MAX_ATTR_LEN, -	   because we don't have any better information */ -	return sdp_uuid_extract_safe(p, SDP_MAX_ATTR_LEN, uuid, scanned); -} -  static sdp_data_t *extract_int(const void *p, int bufsize, int *len)  {  	sdp_data_t *d; @@ -1042,7 +1035,7 @@ static sdp_data_t *extract_uuid(const uint8_t *p, int bufsize, int *len, sdp_rec  	SDPDBG("Extracting UUID");  	memset(d, 0, sizeof(sdp_data_t)); -	if (sdp_uuid_extract_safe(p, bufsize, &d->val.uuid, len) < 0) { +	if (sdp_uuid_extract(p, bufsize, &d->val.uuid, len) < 0) {  		free(d);  		return NULL;  	} @@ -1134,7 +1127,7 @@ static sdp_data_t *extract_str(const void *p, int bufsize, int *len)   * Extract the sequence type and its length, and return offset into buf   * or 0 on failure.   */ -int sdp_extract_seqtype_safe(const uint8_t *buf, int bufsize, uint8_t *dtdp, int *size) +int sdp_extract_seqtype(const uint8_t *buf, int bufsize, uint8_t *dtdp, int *size)  {  	uint8_t dtd;  	int scanned = sizeof(uint8_t); @@ -1183,13 +1176,6 @@ int sdp_extract_seqtype_safe(const uint8_t *buf, int bufsize, uint8_t *dtdp, int  	return scanned;  } -int sdp_extract_seqtype(const uint8_t *buf, uint8_t *dtdp, int *size) -{ -	/* Assume buf points to a buffer of size at least SDP_MAX_ATTR_LEN, -	   because we don't have any better information */ -	return sdp_extract_seqtype_safe(buf, SDP_MAX_ATTR_LEN, dtdp, size); -} -  static sdp_data_t *extract_seq(const void *p, int bufsize, int *len, sdp_record_t *rec)  {  	int seqlen, n = 0; @@ -1198,7 +1184,7 @@ static sdp_data_t *extract_seq(const void *p, int bufsize, int *len, sdp_record_  	SDPDBG("Extracting SEQ");  	memset(d, 0, sizeof(sdp_data_t)); -	*len = sdp_extract_seqtype_safe(p, bufsize, &d->dtd, &seqlen); +	*len = sdp_extract_seqtype(p, bufsize, &d->dtd, &seqlen);  	SDPDBG("Sequence Type : 0x%x length : 0x%x\n", d->dtd, seqlen);  	if (*len == 0) @@ -1215,7 +1201,7 @@ static sdp_data_t *extract_seq(const void *p, int bufsize, int *len, sdp_record_  	curr = prev = NULL;  	while (n < seqlen) {  		int attrlen = 0; -		curr = sdp_extract_attr_safe(p, bufsize, &attrlen, rec); +		curr = sdp_extract_attr(p, bufsize, &attrlen, rec);  		if (curr == NULL)  			break; @@ -1235,7 +1221,7 @@ static sdp_data_t *extract_seq(const void *p, int bufsize, int *len, sdp_record_  	return d;  } -sdp_data_t *sdp_extract_attr_safe(const uint8_t *p, int bufsize, int *size, sdp_record_t *rec) +sdp_data_t *sdp_extract_attr(const uint8_t *p, int bufsize, int *size, sdp_record_t *rec)  {  	sdp_data_t *elem;  	int n = 0; @@ -1293,13 +1279,6 @@ sdp_data_t *sdp_extract_attr_safe(const uint8_t *p, int bufsize, int *size, sdp_  	return elem;  } -sdp_data_t *sdp_extract_attr(const uint8_t *p, int *size, sdp_record_t *rec) -{ -	/* Assume p points to a buffer of size at least SDP_MAX_ATTR_LEN, -	   because we don't have any better information */ -	return sdp_extract_attr_safe(p, SDP_MAX_ATTR_LEN, size, rec); -} -  #ifdef SDP_DEBUG  static void attr_print_func(void *value, void *userData)  { @@ -1323,7 +1302,7 @@ void sdp_print_service_attr(sdp_list_t *svcAttrList)  }  #endif -sdp_record_t *sdp_extract_pdu_safe(const uint8_t *buf, int bufsize, int *scanned) +sdp_record_t *sdp_extract_pdu(const uint8_t *buf, int bufsize, int *scanned)  {  	int extracted = 0, seqlen = 0;  	uint8_t dtd; @@ -1331,7 +1310,7 @@ sdp_record_t *sdp_extract_pdu_safe(const uint8_t *buf, int bufsize, int *scanned  	sdp_record_t *rec = sdp_record_alloc();  	const uint8_t *p = buf; -	*scanned = sdp_extract_seqtype_safe(buf, bufsize, &dtd, &seqlen); +	*scanned = sdp_extract_seqtype(buf, bufsize, &dtd, &seqlen);  	p += *scanned;  	bufsize -= *scanned;  	rec->attrlist = NULL; @@ -1354,7 +1333,7 @@ sdp_record_t *sdp_extract_pdu_safe(const uint8_t *buf, int bufsize, int *scanned  		SDPDBG("DTD of attrId : %d Attr id : 0x%x \n", dtd, attr); -		data = sdp_extract_attr_safe(p + n, bufsize - n, &attrlen, rec); +		data = sdp_extract_attr(p + n, bufsize - n, &attrlen, rec);  		SDPDBG("Attr id : 0x%x attrValueLength : %d\n", attr, attrlen); @@ -1386,13 +1365,6 @@ sdp_record_t *sdp_extract_pdu_safe(const uint8_t *buf, int bufsize, int *scanned  	return rec;  } -sdp_record_t *sdp_extract_pdu(const uint8_t *buf, int *scanned) -{ -	/* Assume buf points to a buffer of size at least SDP_MAX_ATTR_LEN, -	   because we don't have any better information */ -	return sdp_extract_pdu_safe(buf, SDP_MAX_ATTR_LEN, scanned); -} -  #ifdef SDP_DEBUG  static void print_dataseq(sdp_data_t *p)  { @@ -3381,7 +3353,7 @@ sdp_record_t *sdp_service_attr_req(sdp_session_t *session, uint32_t handle,  			pdata = rsp_concat_buf.data;  			pdata_len = rsp_concat_buf.data_size;  		} -		rec = sdp_extract_pdu_safe(pdata, pdata_len, &scanned); +		rec = sdp_extract_pdu(pdata, pdata_len, &scanned);  		if (!rec)  			status = -1; @@ -4221,7 +4193,7 @@ int sdp_service_search_attr_req(sdp_session_t *session, const sdp_list_t *search  		 * more data element sequence(s) representing services  		 * for which attributes are returned  		 */ -		scanned = sdp_extract_seqtype_safe(pdata, pdata_len, &dataType, &seqlen); +		scanned = sdp_extract_seqtype(pdata, pdata_len, &dataType, &seqlen);  		SDPDBG("Bytes scanned : %d\n", scanned);  		SDPDBG("Seq length : %d\n", seqlen); @@ -4231,7 +4203,7 @@ int sdp_service_search_attr_req(sdp_session_t *session, const sdp_list_t *search  			pdata_len -= scanned;  			do {  				int recsize = 0; -				sdp_record_t *rec = sdp_extract_pdu_safe(pdata, pdata_len, &recsize); +				sdp_record_t *rec = sdp_extract_pdu(pdata, pdata_len, &recsize);  				if (rec == NULL) {  					SDPERR("SVC REC is null\n");  					status = -1; diff --git a/src/adapter.c b/src/adapter.c index efc66c2e..d0ae3190 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -2143,11 +2143,11 @@ static void create_stored_records_from_keys(char *key, char *value,  	pdata = g_malloc0(size);  	for (i = 0; i < size; i++) { -		 memcpy(tmp, value + (i*2), 2); +		 memcpy(tmp, value + (i * 2), 2);  		 pdata[i] = (uint8_t) strtol(tmp, NULL, 16);  	} -	rec = sdp_extract_pdu(pdata, &len); +	rec = sdp_extract_pdu(pdata, size, &len);  	free(pdata);  	rec_list->recs = sdp_list_append(rec_list->recs, rec); diff --git a/src/sdpd-request.c b/src/sdpd-request.c index ece8cd54..3ddf25ce 100644 --- a/src/sdpd-request.c +++ b/src/sdpd-request.c @@ -106,7 +106,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p  	const uint8_t *p;  	int bufsize; -	scanned = sdp_extract_seqtype_safe(buf, len, &seqType, &data_size); +	scanned = sdp_extract_seqtype(buf, len, &seqType, &data_size);  	debug("Seq type : %d", seqType);  	if (!scanned || (seqType != SDP_SEQ8 && seqType != SDP_SEQ16)) { @@ -175,7 +175,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p  		case SDP_UUID32:  		case SDP_UUID128:  			pElem = malloc(sizeof(uuid_t)); -			status = sdp_uuid_extract_safe(p, bufsize, (uuid_t *) pElem, &localSeqLength); +			status = sdp_uuid_extract(p, bufsize, (uuid_t *) pElem, &localSeqLength);  			if (status == 0) {  				seqlen += localSeqLength;  				p += localSeqLength; diff --git a/src/sdpd-service.c b/src/sdpd-service.c index 09459f43..cf120b89 100644 --- a/src/sdpd-service.c +++ b/src/sdpd-service.c @@ -440,7 +440,7 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, int bufsiz  	sdp_data_t *pAttr = NULL;  	uint32_t handle = 0xffffffff; -	*scanned = sdp_extract_seqtype_safe(p, bufsize, &dtd, &seqlen); +	*scanned = sdp_extract_seqtype(p, bufsize, &dtd, &seqlen);  	p += *scanned;  	bufsize -= *scanned; @@ -498,7 +498,7 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, int bufsiz  		debug("DTD of attrId : %d Attr id : 0x%x", dtd, attrId); -		pAttr = sdp_extract_attr_safe(p + attrSize, bufsize - attrSize, +		pAttr = sdp_extract_attr(p + attrSize, bufsize - attrSize,  							&attrValueLength, rec);  		debug("Attr id : 0x%x attrValueLength : %d", attrId, attrValueLength); diff --git a/src/storage.c b/src/storage.c index ded9a535..f8064254 100644 --- a/src/storage.c +++ b/src/storage.c @@ -756,7 +756,7 @@ sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t ha  	if (!str)  		return NULL; -	size = strlen(str)/2; +	size = strlen(str) / 2;  	pdata = g_malloc0(size);  	for (i = 0; i < size; i++) { @@ -764,7 +764,7 @@ sdp_record_t *fetch_record(const gchar *src, const gchar *dst, const uint32_t ha  		pdata[i] = (uint8_t) strtol(tmp, NULL, 16);  	} -	rec = sdp_extract_pdu(pdata, &len); +	rec = sdp_extract_pdu(pdata, size, &len);  	free(str);  	free(pdata);  | 
