From f2498d869a321eb3370420e9701f519a08a753a8 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 4 Dec 2020 10:06:13 -0800 Subject: [PATCH] Use the internal version of `strdup`. For portability this is better. Keil libc doesn't have it. ZD 11320 --- wolfssh/port.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/wolfssh/port.h b/wolfssh/port.h index ac57c63..3daa57e 100644 --- a/wolfssh/port.h +++ b/wolfssh/port.h @@ -288,9 +288,6 @@ extern "C" { #include #endif - WOLFSSH_API char* wstrnstr(const char*, const char*, unsigned int); - WOLFSSH_API char* wstrncat(char*, const char*, size_t); - #define WMEMCPY(d,s,l) memcpy((d),(s),(l)) #define WMEMSET(b,c,l) memset((b),(c),(l)) #define WMEMCMP(s1,s2,n) memcmp((s1),(s2),(n)) @@ -298,19 +295,24 @@ extern "C" { #define WSTRLEN(s1) strlen((s1)) #define WSTRSTR(s1,s2) strstr((s1),(s2)) - #define WSTRNSTR(s1,s2,n) wstrnstr((s1),(s2),(n)) #define WSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n)) - #define WSTRNCAT(s1,s2,n) wstrncat((s1),(s2),(n)) #define WSTRSPN(s1,s2) strspn((s1),(s2)) #define WSTRCSPN(s1,s2) strcspn((s1),(s2)) + /* for these string functions use internal versions */ + WOLFSSH_API char* wstrnstr(const char*, const char*, unsigned int); + WOLFSSH_API char* wstrncat(char*, const char*, size_t); + WOLFSSL_API char* wstrdup(const char*, void*, int); + #define WSTRNSTR(s1,s2,n) wstrnstr((s1),(s2),(n)) + #define WSTRNCAT(s1,s2,n) wstrncat((s1),(s2),(n)) + #define WSTRDUP(s,h,t) wstrdup((s),(h),(t)) + #ifdef USE_WINDOWS_API #define WSTRNCPY(s1,s2,n) strncpy_s((s1),(n),(s2),(n)) #define WSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n)) #define WSNPRINTF(s,n,f,...) _snprintf_s((s),(n),(n),(f),##__VA_ARGS__) #define WVSNPRINTF(s,n,f,...) _vsnprintf_s((s),(n),(n),(f),##__VA_ARGS__) #define WSTRTOK(s1,s2,s3) strtok_s((s1),(s2),(s3)) - #define WSTRDUP(s,h,t) _strdup((s)) #elif defined(MICROCHIP_MPLAB_HARMONY) || defined(MICROCHIP_PIC32) #include #define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) @@ -318,7 +320,6 @@ extern "C" { #define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__) #define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__) #define WSTRTOK(s1,s2,s3) strtok_r((s1),(s2),(s3)) - #define WSTRDUP(s,h,t) strdup((s)) #elif defined(RENESAS_CSPLUS) #include #define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n)) @@ -326,7 +327,6 @@ extern "C" { #define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),__VA_ARGS__) #define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),__VA_ARGS__) #define WSTRTOK(s1,s2,s3) strtok_r((s1),(s2),(s3)) - #define WSTRDUP(s,h,t) strdup((s)) #else #ifndef FREESCALE_MQX #include @@ -336,8 +336,6 @@ extern "C" { #define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__) #define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__) #define WSTRTOK(s1,s2,s3) strtok_r((s1),(s2),(s3)) - WOLFSSL_API char* wstrdup(const char*, void*, int); - #define WSTRDUP(s,h,t) wstrdup((s),(h),(t)) #endif #endif /* WSTRING_USER */