From ad744c621866ec73b592707c6210ccc7ccbfa387 Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Tue, 2 Dec 2014 11:07:05 +0100 Subject: [PATCH] Randomize source ports for all outgoing connections. Fix for CERT VU#210620. --- core/net/ip64/ip64-addrmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/net/ip64/ip64-addrmap.c b/core/net/ip64/ip64-addrmap.c index 4578d1296..d7cfcb74f 100644 --- a/core/net/ip64/ip64-addrmap.c +++ b/core/net/ip64/ip64-addrmap.c @@ -35,6 +35,8 @@ #include "ip64-conf.h" +#include "lib/random.h" + #include #ifdef IP64_ADDRMAP_CONF_ENTRIES @@ -173,10 +175,8 @@ ip64_addrmap_lookup_port(uint16_t mapped_port, uint8_t protocol) static void increase_mapped_port(void) { - mapped_port++; - if(mapped_port >= LAST_MAPPED_PORT) { - mapped_port = FIRST_MAPPED_PORT; - } + mapped_port = (random_rand() % (LAST_MAPPED_PORT - FIRST_MAPPED_PORT)) + + FIRST_MAPPED_PORT; } /*---------------------------------------------------------------------------*/ struct ip64_addrmap_entry *