diff options
author | Björn Gustavsson <[email protected]> | 2017-11-30 11:57:54 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-11-30 11:57:54 +0100 |
commit | 6fb6f4222f2cf924cbb9174d33c3b3190cfe52f2 (patch) | |
tree | 124498af9e9a04f37536cfcd8911ebe2e752a673 | |
parent | fadc3d671d2edcf15b87719f350451c32c1f4bbb (diff) | |
parent | 3b3a617453af3ea5a731516585888c2373825a1d (diff) | |
download | otp-6fb6f4222f2cf924cbb9174d33c3b3190cfe52f2.tar.gz otp-6fb6f4222f2cf924cbb9174d33c3b3190cfe52f2.tar.bz2 otp-6fb6f4222f2cf924cbb9174d33c3b3190cfe52f2.zip |
Merge branch 'maint'
* maint:
Fix max atom size overflow on 64-bits Erlang by lowering the MAX_ATOM_TABLE_SIZE
Fix integer overflow when set a large maximum value for atom table
-rw-r--r-- | erts/emulator/beam/atom.h | 2 | ||||
-rw-r--r-- | erts/emulator/beam/index.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/erts/emulator/beam/atom.h b/erts/emulator/beam/atom.h index be998a46bd..385120a8d9 100644 --- a/erts/emulator/beam/atom.h +++ b/erts/emulator/beam/atom.h @@ -36,7 +36,7 @@ /* Internal atom cache needs MAX_ATOM_TABLE_SIZE to be less than an unsigned 32 bit integer. See external.c(erts_encode_ext_dist_header_setup) for more details. */ -#define MAX_ATOM_TABLE_SIZE ((MAX_ATOM_INDEX + 1 < (UWORD_CONSTANT(1) << 32)) ? MAX_ATOM_INDEX + 1 : (UWORD_CONSTANT(1) << 32)) +#define MAX_ATOM_TABLE_SIZE ((MAX_ATOM_INDEX + 1 < (UWORD_CONSTANT(1) << 32)) ? MAX_ATOM_INDEX + 1 : ((UWORD_CONSTANT(1) << 31) - 1)) /* Here we use maximum signed interger value to avoid integer overflow */ #else #define MAX_ATOM_TABLE_SIZE (MAX_ATOM_INDEX + 1) #endif diff --git a/erts/emulator/beam/index.c b/erts/emulator/beam/index.c index 93d1111904..be1771b037 100644 --- a/erts/emulator/beam/index.c +++ b/erts/emulator/beam/index.c @@ -58,7 +58,7 @@ IndexTable* erts_index_init(ErtsAlcType_t type, IndexTable* t, char* name, int size, int limit, HashFunctions fun) { - Uint base_size = ((limit+INDEX_PAGE_SIZE-1)/INDEX_PAGE_SIZE)*sizeof(IndexSlot*); + Uint base_size = (((Uint)limit+INDEX_PAGE_SIZE-1)/INDEX_PAGE_SIZE)*sizeof(IndexSlot*); hash_init(type, &t->htable, name, 3*size/4, fun); t->size = 0; |