Adapt prototype of net_accept() for explicit size
diff --git a/library/error.c b/library/error.c
index 36b9032..2775a40 100644
--- a/library/error.c
+++ b/library/error.c
@@ -683,6 +683,8 @@
         mbedtls_snprintf( buf, buflen, "NET - Connection was reset by peer" );
     if( use_ret == -(MBEDTLS_ERR_NET_UNKNOWN_HOST) )
         mbedtls_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" );
+    if( use_ret == -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL) )
+        mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" );
 #endif /* MBEDTLS_NET_C */
 
 #if defined(MBEDTLS_OID_C)
diff --git a/library/net.c b/library/net.c
index 568a244..8eb5172 100644
--- a/library/net.c
+++ b/library/net.c
@@ -293,7 +293,8 @@
 /*
  * Accept a connection from a remote client
  */
-int mbedtls_net_accept( int bind_fd, int *client_fd, void *client_ip )
+int mbedtls_net_accept( int bind_fd, int *client_fd,
+                        void *client_ip, size_t buf_size, size_t *ip_len )
 {
     int ret;
     int type;
@@ -353,14 +354,22 @@
         if( client_addr.ss_family == AF_INET )
         {
             struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr;
-            memcpy( client_ip, &addr4->sin_addr.s_addr,
-                        sizeof( addr4->sin_addr.s_addr ) );
+            *ip_len = sizeof( addr4->sin_addr.s_addr );
+
+            if( buf_size < *ip_len )
+                return( MBEDTLS_ERR_NET_BUFFER_TOO_SMALL );
+
+            memcpy( client_ip, &addr4->sin_addr.s_addr, *ip_len );
         }
         else
         {
             struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) &client_addr;
-            memcpy( client_ip, &addr6->sin6_addr.s6_addr,
-                        sizeof( addr6->sin6_addr.s6_addr ) );
+            *ip_len = sizeof( addr6->sin6_addr.s6_addr );
+
+            if( buf_size < *ip_len )
+                return( MBEDTLS_ERR_NET_BUFFER_TOO_SMALL );
+
+            memcpy( client_ip, &addr6->sin6_addr.s6_addr, *ip_len);
         }
     }