summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/segment_manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/segment_manager.c')
-rw-r--r--src/vnet/session/segment_manager.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index 6213cd517f6..cbec493e55f 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -114,7 +114,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 (), smm->seg_name_counter++, 0);