From c4f670fa2424040bd97cc30d083d5cfdacac40b0 Mon Sep 17 00:00:00 2001 From: Emil Ljungdahl <111423223+pando-emil@users.noreply.github.com> Date: Sun, 30 Oct 2022 04:13:25 +0100 Subject: [PATCH] WINDOWS: unsigned long should not be used to store pointers (#1055) On LLP64 systems (read Windows) unsigned long is only 4 bytes wide, which makes it very unsuitable for storing pointers. ----- Additional comments: uintptr_t since c99 or uintptr_t since C++11 see: https://cplusplus.com/reference/cstdint/, https://en.cppreference.com/w/c/types/integer, https://en.cppreference.com/w/cpp/types/integer C11 re-enabled in #1056 --- src/apps/common/CMakeLists.txt | 2 +- src/apps/common/apputils.c | 2 +- src/apps/relay/CMakeLists.txt | 2 +- src/apps/relay/mainrelay.c | 2 +- src/ns_turn_defs.h | 2 +- src/server/ns_turn_maps.h | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/apps/common/CMakeLists.txt b/src/apps/common/CMakeLists.txt index b3f45ace..12457901 100644 --- a/src/apps/common/CMakeLists.txt +++ b/src/apps/common/CMakeLists.txt @@ -23,7 +23,7 @@ endif() if(MSVC OR MINGW) list(APPEND COMMON_DEFINED WINDOWS) - list(APPEND COMMON_LIBS Ws2_32 netapi32) + list(APPEND COMMON_LIBS ws2_32 netapi32) endif() find_package(OpenSSL REQUIRED COMPONENTS Crypto SSL) diff --git a/src/apps/common/apputils.c b/src/apps/common/apputils.c index fd01c6ea..8ce703e3 100644 --- a/src/apps/common/apputils.c +++ b/src/apps/common/apputils.c @@ -49,7 +49,7 @@ #endif #if defined(WINDOWS) - #include + #include #endif #if defined(_MSC_VER) diff --git a/src/apps/relay/CMakeLists.txt b/src/apps/relay/CMakeLists.txt index 227ed8ea..95b1aec4 100644 --- a/src/apps/relay/CMakeLists.txt +++ b/src/apps/relay/CMakeLists.txt @@ -8,7 +8,7 @@ if(NOT HAVE_THREAD_BARRIERS) endif() if(MSVC OR MINGW) - list(APPEND turnserver_LIBS Iphlpapi) + list(APPEND turnserver_LIBS iphlpapi) endif() set(HEADER_FILES diff --git a/src/apps/relay/mainrelay.c b/src/apps/relay/mainrelay.c index dd7adfe9..71c42faf 100644 --- a/src/apps/relay/mainrelay.c +++ b/src/apps/relay/mainrelay.c @@ -34,7 +34,7 @@ #include "prom_server.h" #if defined(WINDOWS) - #include + #include #define WORKING_BUFFER_SIZE 15000 #define MAX_TRIES 3 diff --git a/src/ns_turn_defs.h b/src/ns_turn_defs.h index 1b223c17..eacf7363 100644 --- a/src/ns_turn_defs.h +++ b/src/ns_turn_defs.h @@ -45,7 +45,7 @@ #if defined(WINDOWS) #include -#include +#include #include #else #include diff --git a/src/server/ns_turn_maps.h b/src/server/ns_turn_maps.h index 46b3c008..d4a076e2 100644 --- a/src/server/ns_turn_maps.h +++ b/src/server/ns_turn_maps.h @@ -45,7 +45,7 @@ typedef struct _ur_map ur_map; //////////////// Common Definitions ////// typedef uint64_t ur_map_key_type; -typedef unsigned long ur_map_value_type; +typedef uintptr_t ur_map_value_type; typedef void (*ur_map_del_func)(ur_map_value_type); @@ -158,7 +158,7 @@ int lm_map_foreach_arg(lm_map* map, foreachcb_arg_type func, void* arg); //////////////// UR ADDR MAP ////////////////// -typedef unsigned long ur_addr_map_value_type; +typedef uintptr_t ur_addr_map_value_type; #define ADDR_MAP_SIZE (1024) #define ADDR_ARRAY_SIZE (4)