diff options
author | Nick Desaulniers <ndesaulniers@google.com> | 2016-08-11 00:24:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-08-11 00:24:10 +0000 |
commit | 96eaef2510c31e1b778f447f5fe3d988cabe27ff (patch) | |
tree | fe1bfde7f46b5dd61ae88dd5e72697fb4700214b | |
parent | 187816e5793ad177f6f70fe6270baf1475d74149 (diff) | |
parent | 98a20cd1283b6ee029e871c0876815300475c40a (diff) | |
download | extras-nougat-mr1-dev.tar.gz |
Merge "procrank: fix bounds check to prevent heap overflow" into nyc-mr1-devandroid-cts-7.1_r2nougat-mr1-dev
-rw-r--r-- | libpagemap/pm_memusage.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libpagemap/pm_memusage.c b/libpagemap/pm_memusage.c index 70cfedec..71a5783e 100644 --- a/libpagemap/pm_memusage.c +++ b/libpagemap/pm_memusage.c @@ -89,15 +89,15 @@ void pm_memusage_pswap_add_offset(pm_memusage_t *mu, unsigned int offset) { if (mu->p_swap == NULL) return; - if (offset > mu->p_swap->array_size) { + if (offset >= mu->p_swap->array_size) { fprintf(stderr, "SWAP offset %d is out of swap bounds.\n", offset); return; + } + + if (mu->p_swap->offset_array[offset] == USHRT_MAX) { + fprintf(stderr, "SWAP offset %d ref. count if overflowing ushort type.\n", offset); } else { - if (mu->p_swap->offset_array[offset] == USHRT_MAX) { - fprintf(stderr, "SWAP offset %d ref. count if overflowing ushort type.\n", offset); - } else { - mu->p_swap->offset_array[offset]++; - } + mu->p_swap->offset_array[offset]++; } soff = malloc(sizeof(pm_swap_offset_t)); |