From: JuanJo Ciarlante Date: Sat, 19 Sep 2009 16:33:40 +0000 (+0200) Subject: * fixed win32 non-ipv6 build X-Git-Tag: v2.3-alpha1~240^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d3df224e1210f732b84cf4273fb57993361d4ba;p=thirdparty%2Fopenvpn.git * fixed win32 non-ipv6 build --- diff --git a/buffer.c b/buffer.c index c43cb4700..f69ec709a 100644 --- a/buffer.c +++ b/buffer.c @@ -214,8 +214,10 @@ buf_printf (struct buffer *buf, const char *format, ...) return ret; } -void buf_puts(struct buffer *buf, const char *str) +bool +buf_puts(struct buffer *buf, const char *str) { + int ret = false; uint8_t *ptr = BEND (buf); int cap = buf_forward_capacity (buf); if (cap > 0) @@ -223,7 +225,9 @@ void buf_puts(struct buffer *buf, const char *str) strncpynt ((char *)ptr,str, cap); *(buf->data + buf->capacity - 1) = 0; /* windows vsnprintf needs this */ buf->len += (int) strlen ((char *)ptr); + ret = true; } + return ret; } diff --git a/buffer.h b/buffer.h index 3b24d09e9..0a394a72e 100644 --- a/buffer.h +++ b/buffer.h @@ -276,6 +276,11 @@ bool buf_printf (struct buffer *buf, const char *format, ...) #endif ; +/* + * puts append to a buffer with overflow check + */ +bool buf_puts (struct buffer *buf, const char *str); + /* * Like snprintf but guarantees null termination for size > 0 */ diff --git a/socket.c b/socket.c index 344c0dd26..3340314f9 100644 --- a/socket.c +++ b/socket.c @@ -1173,7 +1173,7 @@ openvpn_connect (socket_descriptor_t sd, } } #else - status = connect (sd, (struct sockaddr *) &remote->sa, sizeof (remote->sa)); + status = connect (sd, &remote->addr.sa, af_addr_size(remote->addr.sa.sa_family)); if (status) status = openvpn_errno_socket (); #endif @@ -2515,9 +2515,9 @@ void setenv_sockaddr (struct env_set *es, const char *name_prefix, const struct openvpn_sockaddr *addr, const bool flags) { char name_buf[256]; - char buf[128]; #ifdef USE_PF_INET6 + char buf[128]; switch(addr->addr.sa.sa_family) { case AF_INET: @@ -2582,7 +2582,7 @@ struct proto_names { const char *display_form; bool is_dgram; bool is_net; - sa_family_t proto_af; + unsigned short proto_af; }; /* Indexed by PROTO_x */ @@ -2629,7 +2629,7 @@ proto_is_tcp(int proto) return (!proto_names[proto].is_dgram)&&proto_names[proto].is_net; } -sa_family_t +unsigned short proto_sa_family(int proto) { if (proto < 0 || proto >= PROTO_N) @@ -2679,7 +2679,9 @@ proto2ascii_all (struct gc_arena *gc) int addr_guess_family(int proto, const char *name) { - sa_family_t ret; +#ifdef USE_PF_INET6 + unsigned short ret; +#endif if (proto) { return proto_sa_family(proto); /* already stamped */ @@ -3270,10 +3272,10 @@ socket_finalize (SOCKET s, { if (io->addrlen != sizeof (io->addr)) bad_address_length (io->addrlen, sizeof (io->addr)); - from->dest.addr.sa = io->addr; + from->dest.addr.in4 = io->addr; } else - CLEAR (from->dest.addr.sa); + CLEAR (from->dest.addr); } if (buf) diff --git a/socket.h b/socket.h index 718805a6a..def8104e7 100644 --- a/socket.h +++ b/socket.h @@ -591,6 +591,7 @@ addr_defined_ipi (const struct link_socket_actual *lsa) #else ASSERT(0); #endif + return false; } static inline bool @@ -702,7 +703,7 @@ addr_inet4or6(struct sockaddr *addr) int addr_guess_family(int proto, const char *name); static inline int -af_addr_size(sa_family_t af) +af_addr_size(unsigned short af) { #if defined(USE_PF_INET6) || defined (USE_PF_UNIX) switch(af) {