Skip to contentSkip to conversation

l2cap: fix signedness bugs

PATCH In review Dan Carpenter 2 participants 2 messages Jul 17, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 l2cap: fix signedness bugs

These variables are only used for math. They should be from -63 to +63. In the original code instead of being negative they would be largish positive numbers. I changed them to ints.

net/bluetooth/l2cap.c +2 -2
index 1b682a5..4a13499 100644
@@ -3795,7 +3795,7 @@ static inline int l2cap_data_channel_iframe(struct sock *sk, u16 rx_control, str
 	u8 tx_seq = __get_txseq(rx_control);
 	u8 req_seq = __get_reqseq(rx_control);
 	u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT;
-	u8 tx_seq_offset, expected_tx_seq_offset;
+	int tx_seq_offset, expected_tx_seq_offset;
 	int num_to_ack = (pi->tx_win/6) + 1;
 	int err = 0;
 
@@ -4080,7 +4080,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
 	struct sock *sk;
 	struct l2cap_pinfo *pi;
 	u16 control, len;
-	u8 tx_seq, req_seq, next_tx_seq_offset, req_seq_offset;
+	int tx_seq, req_seq, next_tx_seq_offset, req_seq_offset;
 
 	sk = l2cap_get_chan_by_scid(&conn->chan_list, cid);
 	if (!sk) {
#1 lore raw

Hi Dan,

Quoted 20 lines · Dan Carpenter

These variables are only used for math. They should be from -63 to +63. In the original code instead of being negative they would be largish positive numbers. I changed them to ints.

net/bluetooth/l2cap.c +1 -1
index 1b682a5..4a13499 100644
@@ -3795,7 +3795,7 @@ static inline int l2cap_data_channel_iframe(struct sock *sk, u16 rx_control, str
 	u8 tx_seq = __get_txseq(rx_control);
 	u8 req_seq = __get_reqseq(rx_control);
 	u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT;
-	u8 tx_seq_offset, expected_tx_seq_offset;
+	int tx_seq_offset, expected_tx_seq_offset;
 	int num_to_ack = (pi->tx_win/6) + 1;
 	int err = 0;
 

net/bluetooth/l2cap.c static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk · line 4086

Quoted 8 lines
net/bluetooth/l2cap.c +1 -1
@@ -4080,7 +4080,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
 	struct sock *sk;
 	struct l2cap_pinfo *pi;
 	u16 control, len;
-	u8 tx_seq, req_seq, next_tx_seq_offset, req_seq_offset;
+	int tx_seq, req_seq, next_tx_seq_offset, req_seq_offset;
 
 	sk = l2cap_get_chan_by_scid(&conn->chan_list, cid);
 	if (!sk) {

I fixed this already. Thanks.

Signature · 2 lines
Gustavo F. Padovan
http://padovan.org