diff options
author | Ilya Enkovich <ilya.enkovich@intel.com> | 2016-06-10 09:23:53 +0000 |
---|---|---|
committer | Ilya Enkovich <ienkovich@gcc.gnu.org> | 2016-06-10 09:23:53 +0000 |
commit | 2cfab6c0f78dbb079737861ab7346420642d1b47 (patch) | |
tree | f999f24e6d94c0335dd840127b6bbabbdbc2e170 /libmpx | |
parent | 27d6ba889b34d38dc13b5f3a8959c576fe0477b1 (diff) | |
download | gcc-2cfab6c0f78dbb079737861ab7346420642d1b47.zip gcc-2cfab6c0f78dbb079737861ab7346420642d1b47.tar.gz gcc-2cfab6c0f78dbb079737861ab7346420642d1b47.tar.bz2 |
mpx_wrappers.c (move_bounds): Fix overflow bug.
libmpx/
2016-06-10 Ilya Enkovich <ilya.enkovich@intel.com>
* mpxwrap/mpx_wrappers.c (move_bounds): Fix overflow bug.
From-SVN: r237292
Diffstat (limited to 'libmpx')
-rw-r--r-- | libmpx/ChangeLog | 4 | ||||
-rw-r--r-- | libmpx/mpxwrap/mpx_wrappers.c | 12 |
2 files changed, 15 insertions, 1 deletions
diff --git a/libmpx/ChangeLog b/libmpx/ChangeLog index 4d58581..636e965 100644 --- a/libmpx/ChangeLog +++ b/libmpx/ChangeLog @@ -1,3 +1,7 @@ +2016-06-10 Ilya Enkovich <ilya.enkovich@intel.com> + + * mpxwrap/mpx_wrappers.c (move_bounds): Fix overflow bug. + 2016-01-20 Matthias Klose <doko@ubuntu.com> * libtool-version: Remove. diff --git a/libmpx/mpxwrap/mpx_wrappers.c b/libmpx/mpxwrap/mpx_wrappers.c index d4c83ef4..171a780 100644 --- a/libmpx/mpxwrap/mpx_wrappers.c +++ b/libmpx/mpxwrap/mpx_wrappers.c @@ -27,6 +27,7 @@ #include "string.h" #include <sys/mman.h> #include <stdint.h> +#include <assert.h> #include "mpxrt/mpxrt.h" void * @@ -418,7 +419,16 @@ move_bounds (void *dst, const void *src, size_t n) else elems_to_copy -= src_bt_index_end + 1; } - src_bd_index_end--; + /* Go to previous table but beware of overflow. + We should have copied all required element + in case src_bd_index_end is 0. */ + if (src_bd_index_end) + src_bd_index_end--; + else + { + assert (!elems_to_copy); + return; + } /* For each bounds table we check if there are valid pointers inside. If there are some, we copy table in pre-counted portions. */ for (; src_bd_index_end > src_bd_index; src_bd_index_end--) |