Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-bt: Commit

system/bt


Commit MetaInfo

Révision87b81e56be35be05149db7649c5848e8c33de92a (tree)
l'heure2017-11-04 04:54:53
AuteurScott Bauer <sbauer@plzd...>
Commiterandroid-build-team Robot

Message de Log

Read the correct amount of attributes

bta_gattc_cache_load currently attempts to read 0xFF attributes into an
allocation sized to num_attr attributes, which can be smaller than 0xFF.

There aren't more than num_attr bytes in correct data, but this breaks
with dynamic buffer overflow checking in CopperheadOS for the read
system call since fread ends up calling read, which obtains the size of
the allocation from the malloc implementation and then aborts due to the
(potential) overflow.

This would also fail with the default enabled _FORTIFY_SOURCE=2 feature
in the Android Open Source Project if osi_malloc was marked with the
alloc_size attribute. The way it wraps malloc loses that information so
fortify checks aren't done for calls like this.

Bug: 37160362
Change-Id: I68bd170d5378c9d9d21cbda376083bc0b857e15c
Signed-off-by: Scott Bauer <sbauer@plzdonthack.me>
[migrated to C++ file, added 0xFFFF limit and wrote commit message]
Signed-off-by: Daniel Micay <danielmicay@gmail.com>
(cherry picked from commit 8eb6493ad56ed4fd8310bf96042cc54eb5b450dd)

Change Summary

Modification

--- a/bta/gatt/bta_gattc_cache.c
+++ b/bta/gatt/bta_gattc_cache.c
@@ -1551,7 +1551,7 @@ bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb)
15511551
15521552 attr = osi_malloc(sizeof(tBTA_GATTC_NV_ATTR) * num_attr);
15531553
1554- if (fread(attr, sizeof(tBTA_GATTC_NV_ATTR), 0xFF, fd) != num_attr) {
1554+ if (fread(attr, sizeof(tBTA_GATTC_NV_ATTR), num_attr, fd) != num_attr) {
15551555 APPL_TRACE_ERROR("%s: can't read GATT attributes: %s", __func__, fname);
15561556 goto done;
15571557 }
Afficher sur ancien navigateur de dépôt.