From 6494889e3ba6b1432258f0a8ed402723607cff21 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 7 Oct 2003 21:46:47 +0000 Subject: Neil Dunbar provided a patch that now makes libcurl check SSL subjectAltNames when matching certs. This is apparently detailed in RFC2818 as the right thing to do. I had to add configure checks for inet_pton() and our own (strictly speaking, code from BIND written by Paul Vixie) provided code for the function for platforms that miss it. --- lib/inet_pton.c | 226 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 lib/inet_pton.c (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c new file mode 100644 index 000000000..0945bdcb4 --- /dev/null +++ b/lib/inet_pton.c @@ -0,0 +1,226 @@ +/* This is from the BIND 4.9.4 release, modified to compile by itself */ + +/* Copyright (c) 1996 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include "setup.h" + +#ifndef HAVE_INET_PTON + +#include +#include +#include +#include +#include +#include +#include + +#define IN6ADDRSZ 16 +#define INADDRSZ 4 +#define INT16SZ 2 + +#ifndef AF_INET6 +#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#endif + +/* + * WARNING: Don't even consider trying to compile this on a system where + * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. + */ + +static int inet_pton4(const char *src, u_char *dst); +static int inet_pton6(const char *src, u_char *dst); + +/* int + * inet_pton(af, src, dst) + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). + * return: + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid (`dst' is untouched in this case) + * -1 if some other error occurred (`dst' is untouched in this case, too) + * author: + * Paul Vixie, 1996. + */ +int +Curl_inet_pton(af, src, dst) + int af; + const char *src; + void *dst; +{ + switch (af) { + case AF_INET: + return (inet_pton4(src, dst)); + case AF_INET6: + return (inet_pton6(src, dst)); + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ +} + +/* int + * inet_pton4(src, dst) + * like inet_aton() but without all the hexadecimal and shorthand. + * return: + * 1 if `src' is a valid dotted quad, else 0. + * notice: + * does not touch `dst' unless it's returning 1. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton4(src, dst) + const char *src; + u_char *dst; +{ + static const char digits[] = "0123456789"; + int saw_digit, octets, ch; + u_char tmp[INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr(digits, ch)) != NULL) { + u_int new = *tp * 10 + (pch - digits); + + if (new > 255) + return (0); + *tp = new; + if (! saw_digit) { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } else if (ch == '.' && saw_digit) { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } else + return (0); + } + if (octets < 4) + return (0); + /* bcopy(tmp, dst, INADDRSZ); */ + memcpy(dst, tmp, INADDRSZ); + return (1); +} + +/* int + * inet_pton6(src, dst) + * convert presentation level address to network order binary form. + * return: + * 1 if `src' is a valid [RFC1884 2.2] address, else 0. + * notice: + * (1) does not touch `dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. + * credit: + * inspired by Mark Andrews. + * author: + * Paul Vixie, 1996. + */ +static int +inet_pton6(src, dst) + const char *src; + u_char *dst; +{ + static const char xdigits_l[] = "0123456789abcdef", + xdigits_u[] = "0123456789ABCDEF"; + u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; + int ch, saw_xdigit; + u_int val; + + memset((tp = tmp), 0, IN6ADDRSZ); + endp = tp + IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') { + curtok = src; + if (!saw_xdigit) { + if (colonp) + return (0); + colonp = tp; + continue; + } + if (tp + INT16SZ > endp) + return (0); + *tp++ = (u_char) (val >> 8) & 0xff; + *tp++ = (u_char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + INADDRSZ) <= endp) && + inet_pton4(curtok, tp) > 0) { + tp += INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) { + if (tp + INT16SZ > endp) + return (0); + *tp++ = (u_char) (val >> 8) & 0xff; + *tp++ = (u_char) val & 0xff; + } + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + for (i = 1; i <= n; i++) { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + /* bcopy(tmp, dst, IN6ADDRSZ); */ + memcpy(dst, tmp, IN6ADDRSZ); + return (1); +} + +#endif /* HAVE_INET_PTON */ -- cgit v1.2.1 From e612f73374d25ba290e3fe27758bb6084851450f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 8 Oct 2003 13:07:08 +0000 Subject: include file fixes --- lib/inet_pton.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 0945bdcb4..6cd6bcac5 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -20,11 +20,21 @@ #ifndef HAVE_INET_PTON +#ifdef HAVE_SYS_PARAM_H #include +#endif +#ifdef HAVE_SYS_TYPES_H #include +#endif +#ifdef HAVE_SYS_SOCKET_H #include +#endif +#ifdef HAVE_NETINET_IN_H #include +#endif +#ifdef HAVE_ARPA_INET_H #include +#endif #include #include -- cgit v1.2.1 From e4adbf401761f62ba71bb6884f7c4de17b6a2a7f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 9 Oct 2003 08:19:01 +0000 Subject: Dominick Meglio fixed this to build fine on MSVC --- lib/inet_pton.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 6cd6bcac5..82eba95bb 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -20,6 +20,11 @@ #ifndef HAVE_INET_PTON +#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#include +#else + #ifdef HAVE_SYS_PARAM_H #include #endif @@ -35,6 +40,7 @@ #ifdef HAVE_ARPA_INET_H #include #endif +#endif #include #include @@ -51,8 +57,8 @@ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static int inet_pton4(const char *src, u_char *dst); -static int inet_pton6(const char *src, u_char *dst); +static int inet_pton4(const char *src, unsigned char *dst); +static int inet_pton6(const char *src, unsigned char *dst); /* int * inet_pton(af, src, dst) @@ -96,11 +102,11 @@ Curl_inet_pton(af, src, dst) static int inet_pton4(src, dst) const char *src; - u_char *dst; + unsigned char *dst; { static const char digits[] = "0123456789"; int saw_digit, octets, ch; - u_char tmp[INADDRSZ], *tp; + unsigned char tmp[INADDRSZ], *tp; saw_digit = 0; octets = 0; @@ -150,11 +156,11 @@ inet_pton4(src, dst) static int inet_pton6(src, dst) const char *src; - u_char *dst; + unsigned char *dst; { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp; + unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; u_int val; @@ -192,8 +198,8 @@ inet_pton6(src, dst) } if (tp + INT16SZ > endp) return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; saw_xdigit = 0; val = 0; continue; @@ -209,8 +215,8 @@ inet_pton6(src, dst) if (saw_xdigit) { if (tp + INT16SZ > endp) return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; } if (colonp != NULL) { /* -- cgit v1.2.1 From 749f5387c19449209615b282ac738032f2a890e7 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 14 Oct 2003 12:00:45 +0000 Subject: Gisle Vanem's IPv6-on-Windows patch applied! --- lib/inet_pton.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 82eba95bb..601042e1d 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -20,11 +20,6 @@ #ifndef HAVE_INET_PTON -#if defined(WIN32) && !defined(__GNUC__) || defined(__MINGW32__) -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#include -#else - #ifdef HAVE_SYS_PARAM_H #include #endif @@ -40,7 +35,6 @@ #ifdef HAVE_ARPA_INET_H #include #endif -#endif #include #include @@ -52,6 +46,10 @@ #define AF_INET6 AF_MAX+1 /* just to let this compile */ #endif +#ifdef WIN32 +#define EAFNOSUPPORT WSAEAFNOSUPPORT +#endif + /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. -- cgit v1.2.1 From c964aedf3bb397db3956789680c5cffd158d84ca Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 30 Oct 2003 07:13:13 +0000 Subject: Only compile the ipv6-section for ipv6-enabled libcurls. Should save us some trouble. --- lib/inet_pton.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 601042e1d..568f56506 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -42,10 +42,6 @@ #define INADDRSZ 4 #define INT16SZ 2 -#ifndef AF_INET6 -#define AF_INET6 AF_MAX+1 /* just to let this compile */ -#endif - #ifdef WIN32 #define EAFNOSUPPORT WSAEAFNOSUPPORT #endif @@ -56,7 +52,9 @@ */ static int inet_pton4(const char *src, unsigned char *dst); +#ifdef ENABLE_IPV6 static int inet_pton6(const char *src, unsigned char *dst); +#endif /* int * inet_pton(af, src, dst) @@ -78,8 +76,13 @@ Curl_inet_pton(af, src, dst) switch (af) { case AF_INET: return (inet_pton4(src, dst)); +#ifdef ENABLE_IPV6 +#ifndef AF_INET6 +#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#endif case AF_INET6: return (inet_pton6(src, dst)); +#endif default: errno = EAFNOSUPPORT; return (-1); @@ -138,6 +141,7 @@ inet_pton4(src, dst) return (1); } +#ifdef ENABLE_IPV6 /* int * inet_pton6(src, dst) * convert presentation level address to network order binary form. @@ -236,5 +240,6 @@ inet_pton6(src, dst) memcpy(dst, tmp, IN6ADDRSZ); return (1); } +#endif /* ENABLE_IPV6 */ #endif /* HAVE_INET_PTON */ -- cgit v1.2.1 From 4d17d6876e4b2f08380812c4ec113073b0a14639 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 29 Jan 2004 13:56:45 +0000 Subject: Dan Fandrich's cleanup patch to make pedantic compiler options cause less warnings. Minor edits by me. --- lib/inet_pton.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 568f56506..1cd3f80f4 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -38,6 +38,8 @@ #include #include +#include "inet_pton.h" + #define IN6ADDRSZ 16 #define INADDRSZ 4 #define INT16SZ 2 @@ -68,10 +70,7 @@ static int inet_pton6(const char *src, unsigned char *dst); * Paul Vixie, 1996. */ int -Curl_inet_pton(af, src, dst) - int af; - const char *src; - void *dst; +Curl_inet_pton(int af, const char *src, void *dst) { switch (af) { case AF_INET: @@ -101,9 +100,7 @@ Curl_inet_pton(af, src, dst) * Paul Vixie, 1996. */ static int -inet_pton4(src, dst) - const char *src; - unsigned char *dst; +inet_pton4(const char *src, unsigned char *dst) { static const char digits[] = "0123456789"; int saw_digit, octets, ch; @@ -156,9 +153,7 @@ inet_pton4(src, dst) * Paul Vixie, 1996. */ static int -inet_pton6(src, dst) - const char *src; - unsigned char *dst; +inet_pton6(const char *src, unsigned char *dst) { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; -- cgit v1.2.1 From d72ca96a43430b9182e534be211acb1bc85bad5f Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 18 Aug 2004 06:12:01 +0000 Subject: indented the code curl-style --- lib/inet_pton.c | 246 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 123 insertions(+), 123 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 1cd3f80f4..24820fe25 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -72,21 +72,21 @@ static int inet_pton6(const char *src, unsigned char *dst); int Curl_inet_pton(int af, const char *src, void *dst) { - switch (af) { - case AF_INET: - return (inet_pton4(src, dst)); + switch (af) { + case AF_INET: + return (inet_pton4(src, dst)); #ifdef ENABLE_IPV6 #ifndef AF_INET6 #define AF_INET6 AF_MAX+1 /* just to let this compile */ #endif - case AF_INET6: - return (inet_pton6(src, dst)); + case AF_INET6: + return (inet_pton6(src, dst)); #endif - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ } /* int @@ -102,40 +102,40 @@ Curl_inet_pton(int af, const char *src, void *dst) static int inet_pton4(const char *src, unsigned char *dst) { - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - u_int new = *tp * 10 + (pch - digits); - - if (new > 255) - return (0); - *tp = new; - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - /* bcopy(tmp, dst, INADDRSZ); */ - memcpy(dst, tmp, INADDRSZ); - return (1); + static const char digits[] = "0123456789"; + int saw_digit, octets, ch; + unsigned char tmp[INADDRSZ], *tp; + + saw_digit = 0; + octets = 0; + *(tp = tmp) = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr(digits, ch)) != NULL) { + u_int new = *tp * 10 + (pch - digits); + + if (new > 255) + return (0); + *tp = new; + if (! saw_digit) { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } else if (ch == '.' && saw_digit) { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } else + return (0); + } + if (octets < 4) + return (0); + /* bcopy(tmp, dst, INADDRSZ); */ + memcpy(dst, tmp, INADDRSZ); + return (1); } #ifdef ENABLE_IPV6 @@ -155,85 +155,85 @@ inet_pton4(const char *src, unsigned char *dst) static int inet_pton6(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - u_int val; - - memset((tp = tmp), 0, IN6ADDRSZ); - endp = tp + IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; - - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - /* bcopy(tmp, dst, IN6ADDRSZ); */ - memcpy(dst, tmp, IN6ADDRSZ); - return (1); + static const char xdigits_l[] = "0123456789abcdef", + xdigits_u[] = "0123456789ABCDEF"; + unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; + int ch, saw_xdigit; + u_int val; + + memset((tp = tmp), 0, IN6ADDRSZ); + endp = tp + IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = *src++) != '\0') { + const char *pch; + + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') { + curtok = src; + if (!saw_xdigit) { + if (colonp) + return (0); + colonp = tp; + continue; + } + if (tp + INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + INADDRSZ) <= endp) && + inet_pton4(curtok, tp) > 0) { + tp += INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) { + if (tp + INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + } + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; + + for (i = 1; i <= n; i++) { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + /* bcopy(tmp, dst, IN6ADDRSZ); */ + memcpy(dst, tmp, IN6ADDRSZ); + return (1); } #endif /* ENABLE_IPV6 */ -- cgit v1.2.1 From 566f7b5e5856f73eb970834a1635e501a3af5eb4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 19 Aug 2004 09:37:22 +0000 Subject: simplified expression --- lib/inet_pton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 24820fe25..c79b46335 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -108,7 +108,8 @@ inet_pton4(const char *src, unsigned char *dst) saw_digit = 0; octets = 0; - *(tp = tmp) = 0; + tp = tmp; + *tp = 0; while ((ch = *src++) != '\0') { const char *pch; -- cgit v1.2.1 From 39af394a1c3ae1d8ac71ad263a7c524988702c2e Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 6 Oct 2004 07:50:18 +0000 Subject: removed tabs and trailing whitespace from source --- lib/inet_pton.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index c79b46335..9eb199af5 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -40,9 +40,9 @@ #include "inet_pton.h" -#define IN6ADDRSZ 16 -#define INADDRSZ 4 -#define INT16SZ 2 +#define IN6ADDRSZ 16 +#define INADDRSZ 4 +#define INT16SZ 2 #ifdef WIN32 #define EAFNOSUPPORT WSAEAFNOSUPPORT @@ -53,21 +53,21 @@ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static int inet_pton4(const char *src, unsigned char *dst); +static int inet_pton4(const char *src, unsigned char *dst); #ifdef ENABLE_IPV6 -static int inet_pton6(const char *src, unsigned char *dst); +static int inet_pton6(const char *src, unsigned char *dst); #endif /* int * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). + * convert from presentation format (which usually means ASCII printable) + * to network format (which is usually some kind of binary format). * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) + * 1 if the address was valid for the specified address family + * 0 if the address wasn't valid (`dst' is untouched in this case) + * -1 if some other error occurred (`dst' is untouched in this case, too) * author: - * Paul Vixie, 1996. + * Paul Vixie, 1996. */ int Curl_inet_pton(int af, const char *src, void *dst) @@ -76,8 +76,8 @@ Curl_inet_pton(int af, const char *src, void *dst) case AF_INET: return (inet_pton4(src, dst)); #ifdef ENABLE_IPV6 -#ifndef AF_INET6 -#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#ifndef AF_INET6 +#define AF_INET6 AF_MAX+1 /* just to let this compile */ #endif case AF_INET6: return (inet_pton6(src, dst)); @@ -91,13 +91,13 @@ Curl_inet_pton(int af, const char *src, void *dst) /* int * inet_pton4(src, dst) - * like inet_aton() but without all the hexadecimal and shorthand. + * like inet_aton() but without all the hexadecimal and shorthand. * return: - * 1 if `src' is a valid dotted quad, else 0. + * 1 if `src' is a valid dotted quad, else 0. * notice: - * does not touch `dst' unless it's returning 1. + * does not touch `dst' unless it's returning 1. * author: - * Paul Vixie, 1996. + * Paul Vixie, 1996. */ static int inet_pton4(const char *src, unsigned char *dst) @@ -142,16 +142,16 @@ inet_pton4(const char *src, unsigned char *dst) #ifdef ENABLE_IPV6 /* int * inet_pton6(src, dst) - * convert presentation level address to network order binary form. + * convert presentation level address to network order binary form. * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. + * 1 if `src' is a valid [RFC1884 2.2] address, else 0. * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. + * (1) does not touch `dst' unless it's returning 1. + * (2) :: in a full address is silently ignored. * credit: - * inspired by Mark Andrews. + * inspired by Mark Andrews. * author: - * Paul Vixie, 1996. + * Paul Vixie, 1996. */ static int inet_pton6(const char *src, unsigned char *dst) @@ -206,7 +206,7 @@ inet_pton6(const char *src, unsigned char *dst) inet_pton4(curtok, tp) > 0) { tp += INADDRSZ; saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ + break; /* '\0' was seen by inet_pton4(). */ } return (0); } -- cgit v1.2.1 From a07dcfd8507482bf7a2f9c83ed16d1107f056188 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 17 Dec 2004 20:18:53 +0000 Subject: Renamed a variable to avoid conflict with a C++ reserved word. --- lib/inet_pton.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 9eb199af5..e8d4636b3 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -74,13 +74,13 @@ Curl_inet_pton(int af, const char *src, void *dst) { switch (af) { case AF_INET: - return (inet_pton4(src, dst)); + return (inet_pton4(src, (unsigned char *)dst)); #ifdef ENABLE_IPV6 #ifndef AF_INET6 -#define AF_INET6 AF_MAX+1 /* just to let this compile */ +#define AF_INET6 (AF_MAX+1) /* just to let this compile */ #endif case AF_INET6: - return (inet_pton6(src, dst)); + return (inet_pton6(src, (unsigned char *)dst)); #endif default: errno = EAFNOSUPPORT; @@ -114,11 +114,11 @@ inet_pton4(const char *src, unsigned char *dst) const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - u_int new = *tp * 10 + (pch - digits); + u_int val = *tp * 10 + (pch - digits); - if (new > 255) + if (val > 255) return (0); - *tp = new; + *tp = val; if (! saw_digit) { if (++octets > 4) return (0); -- cgit v1.2.1 From 6b1220b61d5ed2481dbf31714a68be6ef6eed3da Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 26 Apr 2005 13:08:49 +0000 Subject: Cory Nelson's work on nuking compiler warnings when building on x64 with VS2005. --- lib/inet_pton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index e8d4636b3..35eef49d0 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -114,7 +114,7 @@ inet_pton4(const char *src, unsigned char *dst) const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - u_int val = *tp * 10 + (pch - digits); + u_int val = *tp * 10 + (u_int)(pch - digits); if (val > 255) return (0); -- cgit v1.2.1 From df03d5a8b21a66472420116f2b3e76ba1c268a82 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Thu, 8 Dec 2005 22:59:58 +0000 Subject: Replaced nonstandard u_char and u_int types --- lib/inet_pton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 35eef49d0..c290330cb 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -114,7 +114,7 @@ inet_pton4(const char *src, unsigned char *dst) const char *pch; if ((pch = strchr(digits, ch)) != NULL) { - u_int val = *tp * 10 + (u_int)(pch - digits); + unsigned int val = *tp * 10 + (unsigned int)(pch - digits); if (val > 255) return (0); @@ -161,7 +161,7 @@ inet_pton6(const char *src, unsigned char *dst) unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; - u_int val; + unsigned int val; memset((tp = tmp), 0, IN6ADDRSZ); endp = tp + IN6ADDRSZ; -- cgit v1.2.1 From 5df4be11657fc49d74e1e6b39c0003f7cf2f3772 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Oct 2006 21:05:40 +0000 Subject: Check for USE_WINSOCK instead of WIN32 where the check was done to verify winsock API availability. --- lib/inet_pton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index c290330cb..9b9f88b5e 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -44,7 +44,7 @@ #define INADDRSZ 4 #define INT16SZ 2 -#ifdef WIN32 +#ifdef USE_WINSOCK #define EAFNOSUPPORT WSAEAFNOSUPPORT #endif -- cgit v1.2.1 From a1d598399146984c99baa46db148e87c75261033 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 16 Feb 2007 18:19:35 +0000 Subject: use macros ERRNO, SET_ERRNO(), SOCKERRNO and SET_SOCKERRNO() for errno handling --- lib/inet_pton.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 9b9f88b5e..edffeabca 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -66,6 +66,11 @@ static int inet_pton6(const char *src, unsigned char *dst); * 1 if the address was valid for the specified address family * 0 if the address wasn't valid (`dst' is untouched in this case) * -1 if some other error occurred (`dst' is untouched in this case, too) + * notice: + * On Windows we store the error in the thread errno, not + * in the winsock error code. This is to avoid loosing the + * actual last winsock error. So use macro ERRNO to fetch the + * errno this funtion sets when returning (-1), not SOCKERRNO. * author: * Paul Vixie, 1996. */ @@ -83,7 +88,7 @@ Curl_inet_pton(int af, const char *src, void *dst) return (inet_pton6(src, (unsigned char *)dst)); #endif default: - errno = EAFNOSUPPORT; + SET_ERRNO(EAFNOSUPPORT); return (-1); } /* NOTREACHED */ -- cgit v1.2.1 From c514a2a89aa1c1e06b70405eedb4e1f70b27fd10 Mon Sep 17 00:00:00 2001 From: Gisle Vanem Date: Mon, 26 Feb 2007 04:24:26 +0000 Subject: Removed inclusion of and in .c-files since they're already included through "setup.h". --- lib/inet_pton.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index edffeabca..192d0624a 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -23,9 +23,6 @@ #ifdef HAVE_SYS_PARAM_H #include #endif -#ifdef HAVE_SYS_TYPES_H -#include -#endif #ifdef HAVE_SYS_SOCKET_H #include #endif -- cgit v1.2.1 From 8fe9376d542ef4f11b2049190de363f7b79436ec Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 4 Apr 2007 06:06:36 +0000 Subject: move WinSock definitions of EBADF, EINTR, EINVAL and EAFNOSUPPORT to setup_once.h --- lib/inet_pton.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 192d0624a..fb7feef28 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -41,10 +41,6 @@ #define INADDRSZ 4 #define INT16SZ 2 -#ifdef USE_WINSOCK -#define EAFNOSUPPORT WSAEAFNOSUPPORT -#endif - /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. -- cgit v1.2.1 From 038fe54e2133119e7836d79ea4aaa5ca705159fc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 13 Apr 2007 07:57:31 +0000 Subject: fix compiler warning --- lib/inet_pton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index fb7feef28..163df3ce3 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -116,7 +116,7 @@ inet_pton4(const char *src, unsigned char *dst) if (val > 255) return (0); - *tp = val; + *tp = (unsigned char)val; if (! saw_digit) { if (++octets > 4) return (0); -- cgit v1.2.1 From ad6e28073c985a42e8b15d2234baa7ef67ffcb35 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 5 Nov 2007 09:45:09 +0000 Subject: removed space after if and while before the parenthesis for better source code consistency --- lib/inet_pton.c | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 163df3ce3..e7ad83bbb 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -111,26 +111,28 @@ inet_pton4(const char *src, unsigned char *dst) while ((ch = *src++) != '\0') { const char *pch; - if ((pch = strchr(digits, ch)) != NULL) { + if((pch = strchr(digits, ch)) != NULL) { unsigned int val = *tp * 10 + (unsigned int)(pch - digits); - if (val > 255) + if(val > 255) return (0); *tp = (unsigned char)val; - if (! saw_digit) { - if (++octets > 4) + if(! saw_digit) { + if(++octets > 4) return (0); saw_digit = 1; } - } else if (ch == '.' && saw_digit) { - if (octets == 4) + } + else if(ch == '.' && saw_digit) { + if(octets == 4) return (0); *++tp = 0; saw_digit = 0; - } else + } + else return (0); } - if (octets < 4) + if(octets < 4) return (0); /* bcopy(tmp, dst, INADDRSZ); */ memcpy(dst, tmp, INADDRSZ); @@ -165,8 +167,8 @@ inet_pton6(const char *src, unsigned char *dst) endp = tp + IN6ADDRSZ; colonp = NULL; /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') + if(*src == ':') + if(*++src != ':') return (0); curtok = src; saw_xdigit = 0; @@ -174,25 +176,25 @@ inet_pton6(const char *src, unsigned char *dst) while ((ch = *src++) != '\0') { const char *pch; - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + if((pch = strchr((xdigits = xdigits_l), ch)) == NULL) pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { + if(pch != NULL) { val <<= 4; val |= (pch - xdigits); - if (val > 0xffff) + if(val > 0xffff) return (0); saw_xdigit = 1; continue; } - if (ch == ':') { + if(ch == ':') { curtok = src; - if (!saw_xdigit) { - if (colonp) + if(!saw_xdigit) { + if(colonp) return (0); colonp = tp; continue; } - if (tp + INT16SZ > endp) + if(tp + INT16SZ > endp) return (0); *tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char) val & 0xff; @@ -200,7 +202,7 @@ inet_pton6(const char *src, unsigned char *dst) val = 0; continue; } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && + if(ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) { tp += INADDRSZ; saw_xdigit = 0; @@ -208,13 +210,13 @@ inet_pton6(const char *src, unsigned char *dst) } return (0); } - if (saw_xdigit) { - if (tp + INT16SZ > endp) + if(saw_xdigit) { + if(tp + INT16SZ > endp) return (0); *tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char) val & 0xff; } - if (colonp != NULL) { + if(colonp != NULL) { /* * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. @@ -228,7 +230,7 @@ inet_pton6(const char *src, unsigned char *dst) } tp = endp; } - if (tp != endp) + if(tp != endp) return (0); /* bcopy(tmp, dst, IN6ADDRSZ); */ memcpy(dst, tmp, IN6ADDRSZ); -- cgit v1.2.1 From cbd1a77ec24e397d05f20c6de106625676343c9d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 7 Nov 2007 09:21:35 +0000 Subject: if () => if() while () => while() and some other minor re-indentings --- lib/inet_pton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index e7ad83bbb..26a13724f 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -108,7 +108,7 @@ inet_pton4(const char *src, unsigned char *dst) octets = 0; tp = tmp; *tp = 0; - while ((ch = *src++) != '\0') { + while((ch = *src++) != '\0') { const char *pch; if((pch = strchr(digits, ch)) != NULL) { @@ -173,7 +173,7 @@ inet_pton6(const char *src, unsigned char *dst) curtok = src; saw_xdigit = 0; val = 0; - while ((ch = *src++) != '\0') { + while((ch = *src++) != '\0') { const char *pch; if((pch = strchr((xdigits = xdigits_l), ch)) == NULL) -- cgit v1.2.1 From ad61b58036bf2b64916b4a66f46f393c68da872c Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 14 Oct 2008 02:35:39 +0000 Subject: fix compiler warning --- lib/inet_pton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 26a13724f..285284fd1 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -221,8 +221,8 @@ inet_pton6(const char *src, unsigned char *dst) * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const int n = tp - colonp; - int i; + const long n = tp - colonp; + long i; for (i = 1; i <= n; i++) { endp[- i] = colonp[n - i]; -- cgit v1.2.1 From 73060b4523ce76f50a0393c17c540a73225f2977 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 17 Nov 2008 02:40:41 +0000 Subject: backport fix for failures to reject certain malformed literals --- lib/inet_pton.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 285284fd1..9189ce675 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -74,9 +74,6 @@ Curl_inet_pton(int af, const char *src, void *dst) case AF_INET: return (inet_pton4(src, (unsigned char *)dst)); #ifdef ENABLE_IPV6 -#ifndef AF_INET6 -#define AF_INET6 (AF_MAX+1) /* just to let this compile */ -#endif case AF_INET6: return (inet_pton6(src, (unsigned char *)dst)); #endif @@ -114,6 +111,8 @@ inet_pton4(const char *src, unsigned char *dst) if((pch = strchr(digits, ch)) != NULL) { unsigned int val = *tp * 10 + (unsigned int)(pch - digits); + if(saw_digit && *tp == 0) + return (0); if(val > 255) return (0); *tp = (unsigned char)val; @@ -134,7 +133,6 @@ inet_pton4(const char *src, unsigned char *dst) } if(octets < 4) return (0); - /* bcopy(tmp, dst, INADDRSZ); */ memcpy(dst, tmp, INADDRSZ); return (1); } @@ -181,9 +179,8 @@ inet_pton6(const char *src, unsigned char *dst) if(pch != NULL) { val <<= 4; val |= (pch - xdigits); - if(val > 0xffff) + if(++saw_xdigit > 4) return (0); - saw_xdigit = 1; continue; } if(ch == ':') { @@ -224,6 +221,8 @@ inet_pton6(const char *src, unsigned char *dst) const long n = tp - colonp; long i; + if(tp == endp) + return (0); for (i = 1; i <= n; i++) { endp[- i] = colonp[n - i]; colonp[n - i] = 0; @@ -232,7 +231,6 @@ inet_pton6(const char *src, unsigned char *dst) } if(tp != endp) return (0); - /* bcopy(tmp, dst, IN6ADDRSZ); */ memcpy(dst, tmp, IN6ADDRSZ); return (1); } -- cgit v1.2.1 From bb60fe0c1af619ff1507424fa2b27dc458a7215b Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 8 Jun 2010 23:09:42 +0200 Subject: inet_pton: warnings: use size_t to store pointer deltas --- lib/inet_pton.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 9189ce675..db4f39307 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -159,7 +159,7 @@ inet_pton6(const char *src, unsigned char *dst) unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; - unsigned int val; + size_t val; memset((tp = tmp), 0, IN6ADDRSZ); endp = tp + IN6ADDRSZ; @@ -218,8 +218,8 @@ inet_pton6(const char *src, unsigned char *dst) * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const long n = tp - colonp; - long i; + const size_t n = tp - colonp; + size_t i; if(tp == endp) return (0); -- cgit v1.2.1 From b3d39275f5f6b8e4443ea84e89348c7577680acc Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Thu, 25 Nov 2010 02:20:14 +0100 Subject: inet_pton: fix compiler warning warning C4146: unary minus operator applied to unsigned type, result still unsigned --- lib/inet_pton.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index db4f39307..967e30fb1 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -218,14 +218,14 @@ inet_pton6(const char *src, unsigned char *dst) * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const size_t n = tp - colonp; - size_t i; + const ssize_t n = tp - colonp; + ssize_t i; if(tp == endp) return (0); for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; + *(endp - i) = *(colonp + n - i); + *(colonp + n - i) = 0; } tp = endp; } -- cgit v1.2.1 From 1702a2c08d3a0ed5945f34e6cd38436611f65164 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Tue, 19 Apr 2011 15:54:13 +0200 Subject: Fix a couple of spelling errors in lib/ Found with codespell. --- lib/inet_pton.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 967e30fb1..d2a54e9f3 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -61,9 +61,9 @@ static int inet_pton6(const char *src, unsigned char *dst); * -1 if some other error occurred (`dst' is untouched in this case, too) * notice: * On Windows we store the error in the thread errno, not - * in the winsock error code. This is to avoid loosing the + * in the winsock error code. This is to avoid losing the * actual last winsock error. So use macro ERRNO to fetch the - * errno this funtion sets when returning (-1), not SOCKERRNO. + * errno this function sets when returning (-1), not SOCKERRNO. * author: * Paul Vixie, 1996. */ -- cgit v1.2.1 From b903186fa0189ff241d756d25d07fdfe9885ae49 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 20 Apr 2011 15:17:42 +0200 Subject: source cleanup: unify look, style and indent levels By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed. --- lib/inet_pton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index d2a54e9f3..d08c7c666 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -223,7 +223,7 @@ inet_pton6(const char *src, unsigned char *dst) if(tp == endp) return (0); - for (i = 1; i <= n; i++) { + for(i = 1; i <= n; i++) { *(endp - i) = *(colonp + n - i); *(colonp + n - i) = 0; } -- cgit v1.2.1 From ef2176109fca302ed89193716b62c3a7113552a3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Sun, 24 Jul 2011 04:39:43 +0200 Subject: errno.h inclusion conditionally done in setup_once.h --- lib/inet_pton.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index d08c7c666..5a781abf5 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -33,7 +33,6 @@ #include #endif #include -#include #include "inet_pton.h" -- cgit v1.2.1 From f1586cb4775681810afd8e6626e7842d459f3b85 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 26 Jul 2011 17:23:27 +0200 Subject: stdio.h, stdlib.h, string.h, stdarg.h and ctype.h inclusion done in setup_once.h --- lib/inet_pton.c | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/inet_pton.c') diff --git a/lib/inet_pton.c b/lib/inet_pton.c index 5a781abf5..021f48d52 100644 --- a/lib/inet_pton.c +++ b/lib/inet_pton.c @@ -32,7 +32,6 @@ #ifdef HAVE_ARPA_INET_H #include #endif -#include #include "inet_pton.h" -- cgit v1.2.1