Skip to contentSkip to conversation

audio/AVRCP: Fix checking for handler pointer instead of pdu_id

PATCH In review Luiz Augusto von Dentz 1 participant 2 messages Feb 3, 2014 – Feb 5, 2014 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 audio/AVRCP: Fix checking for handler pointer instead of pdu_id

From: Luiz Augusto von Dentz <[email protected]>

The code may not find a valid handler for the pdu_id, in that case the handler would not be NULL because the handlers table is not NULL terminated, instead the code should check if pdu_id really matches.

---
 profiles/audio/avrcp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
profiles/audio/avrcp.c +4 -4
index 12f7faa..4532d85 100644
@@ -1673,7 +1673,7 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
 			break;
 	}
 
-	if (!handler || handler->code != *code) {
+	if (handler->pdu_id != pdu->pdu_id || handler->code != *code) {
 		pdu->params[0] = AVRCP_STATUS_INVALID_COMMAND;
 		goto err_metadata;
 	}
@@ -1734,12 +1734,12 @@ static size_t handle_browsing_pdu(struct avctp *conn,
 
 	for (handler = browsing_handlers; handler->pdu_id; handler++) {
 		if (handler->pdu_id == pdu->pdu_id)
-			break;
+			goto done;
 	}
 
-	if (handler == NULL || handler->func == NULL)
-		return avrcp_browsing_general_reject(operands);
+	return avrcp_browsing_general_reject(operands);
 
+done:
 	session->transaction = transaction;
 	handler->func(session, pdu, transaction);
 	return AVRCP_BROWSING_HEADER_LENGTH + ntohs(pdu->param_len);
Signature · 1 line
1.8.4.2
author maintainer
#1 lore raw

Hi,

Quoted 39 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

The code may not find a valid handler for the pdu_id, in that case the handler would not be NULL because the handlers table is not NULL terminated, instead the code should check if pdu_id really matches.

---
 profiles/audio/avrcp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
profiles/audio/avrcp.c +4 -5
index 12f7faa..4532d85 100644
@@ -1673,7 +1673,7 @@ static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
                        break;
        }
 
-       if (!handler || handler->code != *code) {
+       if (handler->pdu_id != pdu->pdu_id || handler->code != *code) {
                pdu->params[0] = AVRCP_STATUS_INVALID_COMMAND;
                goto err_metadata;
        }
@@ -1734,12 +1734,12 @@ static size_t handle_browsing_pdu(struct avctp *conn,
 
        for (handler = browsing_handlers; handler->pdu_id; handler++) {
                if (handler->pdu_id == pdu->pdu_id)
-                       break;
+                       goto done;
        }
 
-       if (handler == NULL || handler->func == NULL)
-               return avrcp_browsing_general_reject(operands);
+       return avrcp_browsing_general_reject(operands);
 
+done:
        session->transaction = transaction;
        handler->func(session, pdu, transaction);
        return AVRCP_BROWSING_HEADER_LENGTH + ntohs(pdu->param_len);
--
Quoted 1 line

1.8.4.2

Pushed.

Signature · 1 line
Luiz Augusto von Dentz