]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
* fixed win32 non-ipv6 build
authorJuanJo Ciarlante <jjo@google.com>
Sat, 19 Sep 2009 16:33:40 +0000 (18:33 +0200)
committerJuanJo Ciarlante <juanjosec@gmail.com>
Fri, 25 Mar 2011 12:30:29 +0000 (13:30 +0100)
buffer.c
buffer.h
socket.c
socket.h

index c43cb47004a6bef1f0ef49d1c9b24e9173e51b1a..f69ec709a47e5a739e386d99136f46c7457d35f6 100644 (file)
--- 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;
 }
  
 
index 3b24d09e94ab4ee4537260d7f1e4f6e86bedd8db..0a394a72e3223896e065b3d7068ad23e9dea540e 100644 (file)
--- 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
  */
index 344c0dd260a9b538da72e04a6f43456d861c6c4a..3340314f9b40bcea5c93bb355f5eea70cc40d4ab 100644 (file)
--- 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_
+unsigned shor
 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)
index 718805a6ab05f938dc863d2828d83afd447b1bc7..def8104e7b48be7d6725bc2b31072417dd2ff752 100644 (file)
--- 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) {