summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmysql/libmysql.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index eff8c87ee3f..62ad8f398e9 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -1354,7 +1354,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
my_gethostbyname_r_free();
goto error;
}
- memcpy(&sock_addr.sin_addr,hp->h_addr, (size_t) hp->h_length);
+ memcpy(&sock_addr.sin_addr, hp->h_addr,
+ min(sizeof(sock_addr.sin_addr), (size_t) hp->h_length));
my_gethostbyname_r_free();
}
sock_addr.sin_port = (ushort) htons((ushort) port);