diff options
author | Florin Coras <fcoras@cisco.com> | 2019-05-09 14:11:38 -0700 |
---|---|---|
committer | Florin Coras <fcoras@cisco.com> | 2019-05-09 14:11:38 -0700 |
commit | 725c6c416439d7a828aa587a93b9cc1cb0177a5d (patch) | |
tree | 4a8a4c3747aba37e8674efc0df33e803f497941b /src/vnet/session/segment_manager.c | |
parent | 6f05f724f4091acde82ef39e941a1ef819e53893 (diff) |
session: fix segment size rounding and size init
Change-Id: Iceb2a46802ed13f319cb16f1df236b11dc3c00f6
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/segment_manager.c')
-rw-r--r-- | src/vnet/session/segment_manager.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c index c8d4be5c113..f7b4c312a84 100644 --- a/src/vnet/session/segment_manager.c +++ b/src/vnet/session/segment_manager.c @@ -224,7 +224,9 @@ segment_manager_add_segment (segment_manager_t * sm, u32 segment_size) */ segment_size = segment_size ? segment_size : props->add_segment_size; page_size = clib_mem_get_page_size (); - segment_size = (segment_size + page_size - 1) & ~(page_size - 1); + /* Protect against segment size u32 wrap */ + segment_size = clib_max (segment_size + page_size - 1, segment_size); + segment_size = segment_size & ~(page_size - 1); if (props->segment_type != SSVM_SEGMENT_PRIVATE) { seg_name = format (0, "%d-%d%c", getpid (), segment_name_counter++, 0); |