Module Name:    src
Committed By:   kamil
Date:           Wed Jul 25 19:03:50 UTC 2018

Modified Files:
        src/usr.sbin/bta2dpd/bta2dpd: avdtp.c

Log Message:
Avoid potential undefined behavior in bta2dpd(8)

The operator >> causes implicit promotion to int.

There is need to cast the result back to uint8_t in order to save the
return value to a data undef a pointe of type uint8_t.

Requested by GCC when building with Undefined Behavior Sanitizer.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/bta2dpd/bta2dpd/avdtp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/bta2dpd/bta2dpd/avdtp.c
diff -u src/usr.sbin/bta2dpd/bta2dpd/avdtp.c:1.1 src/usr.sbin/bta2dpd/bta2dpd/avdtp.c:1.2
--- src/usr.sbin/bta2dpd/bta2dpd/avdtp.c:1.1	Sat Jan 28 16:55:54 2017
+++ src/usr.sbin/bta2dpd/bta2dpd/avdtp.c	Wed Jul 25 19:03:50 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: avdtp.c,v 1.1 2017/01/28 16:55:54 nat Exp $ */
+/* $NetBSD: avdtp.c,v 1.2 2018/07/25 19:03:50 kamil Exp $ */
 
 /*-
  * Copyright (c) 2015 - 2016 Nathanial Sloss <[email protected]>
@@ -89,7 +89,7 @@ avdtpCheckResponse(int recvfd, bool *isC
 	if (len < AVDTP_LEN_SUCCESS)
 		return ENOMEM;
 
-	*trans = (buffer[0] & TRANSACTIONLABEL) >> TRANSACTIONLABEL_S;
+	*trans = (uint8_t)((buffer[0] & TRANSACTIONLABEL) >> TRANSACTIONLABEL_S);
 	*signalId = buffer[1] & SIGNALID_MASK;
 	if ((buffer[0] & MESSAGETYPE) == COMMAND) {
 		if (datasize)
@@ -377,4 +377,3 @@ avdtpAutoConfigSBC(int fd, int recvfd, u
 auto_config_failed:
 	return EINVAL;
 }
-

Reply via email to