[spice] fix out by one error in call to strncpy

This commit is contained in:
Geoffrey McRae 2018-05-15 09:56:42 +10:00
parent ae382949c8
commit ae1344d1a0

View file

@ -133,7 +133,7 @@ bool spice_discard (const struct SpiceChannel * channel, ssize_t size);
bool spice_connect(const char * host, const short port, const char * password) bool spice_connect(const char * host, const short port, const char * password)
{ {
strncpy(spice.password, password, sizeof(spice.password)); strncpy(spice.password, password, sizeof(spice.password) - 1);
memset(&spice.addr, 0, sizeof(struct sockaddr_in)); memset(&spice.addr, 0, sizeof(struct sockaddr_in));
inet_pton(AF_INET, host, &spice.addr.sin_addr); inet_pton(AF_INET, host, &spice.addr.sin_addr);
spice.addr.sin_family = AF_INET; spice.addr.sin_family = AF_INET;