summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/inet_ntop.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/inet_ntop.c')
-rw-r--r--libs/libcurl/src/inet_ntop.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/libs/libcurl/src/inet_ntop.c b/libs/libcurl/src/inet_ntop.c
index ff318d1a25..60b9e4a6c7 100644
--- a/libs/libcurl/src/inet_ntop.c
+++ b/libs/libcurl/src/inet_ntop.c
@@ -38,7 +38,7 @@
#include "curl_printf.h"
#define IN6ADDRSZ 16
-#define INADDRSZ 4
+/* #define INADDRSZ 4 */
#define INT16SZ 2
/*
@@ -56,7 +56,7 @@
* Returns `dst' (as a const)
* Note:
* - uses no statics
- * - takes a unsigned char* not an in_addr as input
+ * - takes an unsigned char* not an in_addr as input
*/
static char *inet_ntop4(const unsigned char *src, char *dst, size_t size)
{
@@ -74,8 +74,12 @@ static char *inet_ntop4(const unsigned char *src, char *dst, size_t size)
len = strlen(tmp);
if(len == 0 || len >= size) {
- errno = ENOSPC;
- return (NULL);
+#ifdef USE_WINSOCK
+ CURL_SETERRNO(WSAEINVAL);
+#else
+ CURL_SETERRNO(ENOSPC);
+#endif
+ return NULL;
}
strcpy(dst, tmp);
return dst;
@@ -153,8 +157,7 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
if(i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
if(!inet_ntop4(src + 12, tp, sizeof(tmp) - (tp - tmp))) {
- errno = ENOSPC;
- return (NULL);
+ return NULL;
}
tp += strlen(tp);
break;
@@ -171,8 +174,12 @@ static char *inet_ntop6(const unsigned char *src, char *dst, size_t size)
/* Check for overflow, copy, and we are done.
*/
if((size_t)(tp - tmp) > size) {
- errno = ENOSPC;
- return (NULL);
+#ifdef USE_WINSOCK
+ CURL_SETERRNO(WSAEINVAL);
+#else
+ CURL_SETERRNO(ENOSPC);
+#endif
+ return NULL;
}
strcpy(dst, tmp);
return dst;
@@ -197,7 +204,7 @@ char *Curl_inet_ntop(int af, const void *src, char *buf, size_t size)
case AF_INET6:
return inet_ntop6((const unsigned char *)src, buf, size);
default:
- errno = EAFNOSUPPORT;
+ CURL_SETERRNO(SOCKEAFNOSUPPORT);
return NULL;
}
}