• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revisão2736fbc8fcf61e3301f31fec6411f112a7db4720 (tree)
Hora2019-01-15 07:55:19
AutorStanley Tng <stng@goog...>
CommiterJP Sugarbroad

Mensagem de Log

DO NOT MERGE A security fix to check buffer length in l2c_lcc_proc_pdu

Add check to make sure that data buffer is big enough to read the 2
bytes for length.

Also, fix a regression from the previous CL that checks the buffer length
before doing a memcpy. The previous check is too strict causing valid
sized buffers to be rejected. The length check is incorrect and off by the header size.

Bug: 120665616
Test: Run the SL4A Test for LE CoC, BleCoCTest
Merged-In: I30b7a8af11d3a5f974cb39e06b0e3463bebc8e9a
Change-Id: I30b7a8af11d3a5f974cb39e06b0e3463bebc8e9a
(cherry picked from commit fcb1994de1f6ee34b8dc6804a2b32e20bf138073)
(cherry picked from commit 1f1d8b97d80d25023c4c7b04d2aa18d367f4158d)
(cherry picked from commit 6b2739f309f7719086eb8201b3e1a35ba60035f4)
(cherry picked from commit c1fcbd5508a75ae3eaf5f311d706d026fee2fe48)

Mudança Sumário

Diff

--- a/stack/l2cap/l2c_fcr.c
+++ b/stack/l2cap/l2c_fcr.c
@@ -840,7 +840,16 @@ void l2c_lcc_proc_pdu(tL2C_CCB *p_ccb, BT_HDR *p_buf)
840840
841841 if (p_ccb->is_first_seg)
842842 {
843+ if (p_buf->len < sizeof(sdu_length)) {
844+ L2CAP_TRACE_ERROR("%s: buffer length=%d too small. Need at least 2.",
845+ __func__, p_buf->len);
846+ android_errorWriteWithInfoLog(0x534e4554, "120665616", -1, NULL, 0);
847+ /* Discard the buffer */
848+ osi_free(p_buf);
849+ return;
850+ }
843851 STREAM_TO_UINT16(sdu_length, p);
852+
844853 /* Check the SDU Length with local MTU size */
845854 if (sdu_length > p_ccb->local_conn_cfg.mtu)
846855 {
@@ -849,6 +858,9 @@ void l2c_lcc_proc_pdu(tL2C_CCB *p_ccb, BT_HDR *p_buf)
849858 return;
850859 }
851860
861+ p_buf->len -= sizeof(sdu_length);
862+ p_buf->offset += sizeof(sdu_length);
863+
852864 if (sdu_length < p_buf->len) {
853865 L2CAP_TRACE_ERROR("%s: Invalid sdu_length: %d", __func__, sdu_length);
854866 android_errorWriteWithInfoLog(0x534e4554, "112321180", -1, NULL, 0);
@@ -868,8 +880,6 @@ void l2c_lcc_proc_pdu(tL2C_CCB *p_ccb, BT_HDR *p_buf)
868880 p_data->len = 0;
869881 p_ccb->ble_sdu_length = sdu_length;
870882 L2CAP_TRACE_DEBUG ("%s SDU Length = %d",__func__,sdu_length);
871- p_buf->len -= sizeof(sdu_length);
872- p_buf->offset += sizeof(sdu_length);
873883 p_data->offset = 0;
874884 } else {
875885 p_data = p_ccb->ble_sdu;