diff mbox series

[BlueZ] audio/avrcp: Use host/network order as appropriate for pdu->params_len

Message ID 20210808143526.99726-1-marijn.suijten@somainline.org (mailing list archive)
State Accepted
Delegated to: Luiz Von Dentz
Headers show
Series [BlueZ] audio/avrcp: Use host/network order as appropriate for pdu->params_len | expand

Commit Message

Marijn Suijten Aug. 8, 2021, 2:35 p.m. UTC
When comparing against or writing to pdu->params_len to enforce matching
length with total packet length, take into account that pdu->params_len
is in network order (big endian) while packet size (operand_count) is in
host order (usually little endian).

This silently breaks a number of AVRCP commands that perform a quick
length check based on params_len and bail if it doesn't match exactly.

Fixes: e2b0f0d8d ("avrcp: Fix not checking if params_len match number of received bytes")
---
 profiles/audio/avrcp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

bluez.test.bot@gmail.com Aug. 8, 2021, 2:53 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=528099

---Test result---

Test Summary:
CheckPatch                    FAIL      0.27 seconds
GitLint                       FAIL      0.11 seconds
Prep - Setup ELL              PASS      39.58 seconds
Build - Prep                  PASS      0.10 seconds
Build - Configure             PASS      6.91 seconds
Build - Make                  PASS      171.89 seconds
Make Check                    PASS      8.76 seconds
Make Distcheck                PASS      201.76 seconds
Build w/ext ELL - Configure   PASS      6.97 seconds
Build w/ext ELL - Make        PASS      161.73 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
audio/avrcp: Use host/network order as appropriate for pdu->params_len
WARNING:UNKNOWN_COMMIT_ID: Unknown commit id 'e2b0f0d8d', maybe rebased or not pulled?
#15: 
Fixes: e2b0f0d8d ("avrcp: Fix not checking if params_len match number of received bytes")

- total: 0 errors, 1 warnings, 11 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] audio/avrcp: Use host/network order as appropriate for" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
audio/avrcp: Use host/network order as appropriate for pdu->params_len
11: B1 Line exceeds max length (89>80): "Fixes: e2b0f0d8d ("avrcp: Fix not checking if params_len match number of received bytes")"


##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Aug. 9, 2021, 8:36 p.m. UTC | #2
Hi Marijn,

On Sun, Aug 8, 2021 at 9:01 AM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=528099
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    FAIL      0.27 seconds
> GitLint                       FAIL      0.11 seconds
> Prep - Setup ELL              PASS      39.58 seconds
> Build - Prep                  PASS      0.10 seconds
> Build - Configure             PASS      6.91 seconds
> Build - Make                  PASS      171.89 seconds
> Make Check                    PASS      8.76 seconds
> Make Distcheck                PASS      201.76 seconds
> Build w/ext ELL - Configure   PASS      6.97 seconds
> Build w/ext ELL - Make        PASS      161.73 seconds
>
> Details
> ##############################
> Test: CheckPatch - FAIL
> Desc: Run checkpatch.pl script with rule in .checkpatch.conf
> Output:
> audio/avrcp: Use host/network order as appropriate for pdu->params_len
> WARNING:UNKNOWN_COMMIT_ID: Unknown commit id 'e2b0f0d8d', maybe rebased or not pulled?
> #15:
> Fixes: e2b0f0d8d ("avrcp: Fix not checking if params_len match number of received bytes")
>
> - total: 0 errors, 1 warnings, 11 lines checked
>
> NOTE: For some of the reported defects, checkpatch may be able to
>       mechanically convert to the typical style using --fix or --fix-inplace.
>
> "[PATCH] audio/avrcp: Use host/network order as appropriate for" has style problems, please review.
>
> NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
>
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.
>
>
> ##############################
> Test: GitLint - FAIL
> Desc: Run gitlint with rule in .gitlint
> Output:
> audio/avrcp: Use host/network order as appropriate for pdu->params_len
> 11: B1 Line exceeds max length (89>80): "Fixes: e2b0f0d8d ("avrcp: Fix not checking if params_len match number of received bytes")"
>
>
> ##############################
> Test: Prep - Setup ELL - PASS
> Desc: Clone, build, and install ELL
>
> ##############################
> Test: Build - Prep - PASS
> Desc: Prepare environment for build
>
> ##############################
> Test: Build - Configure - PASS
> Desc: Configure the BlueZ source tree
>
> ##############################
> Test: Build - Make - PASS
> Desc: Build the BlueZ source tree
>
> ##############################
> Test: Make Check - PASS
> Desc: Run 'make check'
>
> ##############################
> Test: Make Distcheck - PASS
> Desc: Run distcheck to check the distribution
>
> ##############################
> Test: Build w/ext ELL - Configure - PASS
> Desc: Configure BlueZ source with '--enable-external-ell' configuration
>
> ##############################
> Test: Build w/ext ELL - Make - PASS
> Desc: Build BlueZ source with '--enable-external-ell' configuration
>
>
>
> ---
> Regards,
> Linux Bluetooth

Applied, thanks.
diff mbox series

Patch

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index aee2b85a2..710ab3cdd 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1928,9 +1928,9 @@  static size_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction,
 	operands += sizeof(*pdu);
 	operand_count -= sizeof(*pdu);
 
-	if (pdu->params_len != operand_count) {
+	if (ntohs(pdu->params_len) != operand_count) {
 		DBG("AVRCP PDU parameters length don't match");
-		pdu->params_len = operand_count;
+		pdu->params_len = htons(operand_count);
 	}
 
 	for (handler = session->control_handlers; handler->pdu_id; handler++) {