[Spice-commits] 5 commits - configure.ac server/Makefile.am server/reds.c
Christophe Fergau
teuf at kemper.freedesktop.org
Wed Dec 12 09:20:26 PST 2012
configure.ac | 5 ++++-
server/Makefile.am | 2 ++
server/reds.c | 33 ++++++++++++++++++---------------
3 files changed, 24 insertions(+), 16 deletions(-)
New commits:
commit 07ee2674558bfcda550321bae5c1c0ea27869527
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri Nov 23 16:49:55 2012 +0100
reds: Use g_strlcpy instead of strncpy
reds.c is using strncpy with a length one byte less than the
destination buffer size, and is relying on the fact that the
destination buffers are static global variables.
Now that we depend on glib, we can use g_strlcpy instead, which
avoids relying on such a subtle trick to get a nul-terminated
string.
diff --git a/server/reds.c b/server/reds.c
index 9626318..ec80e9e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -47,6 +47,8 @@
#include <sasl/sasl.h>
#endif
+#include <glib.h>
+
#include <spice/protocol.h>
#include <spice/vd_agent.h>
#include <spice/stats.h>
@@ -352,7 +354,7 @@ StatNodeRef stat_add_node(StatNodeRef parent, const char *name, int visible)
spice_assert(!(node->flags & SPICE_STAT_NODE_FLAG_ENABLED));
node->value = 0;
node->flags = SPICE_STAT_NODE_FLAG_ENABLED | (visible ? SPICE_STAT_NODE_FLAG_VISIBLE : 0);
- strncpy(node->name, name, sizeof(node->name));
+ g_strlcpy(node->name, name, sizeof(node->name));
insert_stat_node(parent, ref);
pthread_mutex_unlock(&reds->stat_lock);
return ref;
@@ -3982,7 +3984,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *s, int port)
SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *s, const char *addr, int flags)
{
spice_assert(reds == s);
- strncpy(spice_addr, addr, sizeof(spice_addr)-1);
+ g_strlcpy(spice_addr, addr, sizeof(spice_addr));
if (flags & SPICE_ADDR_FLAG_IPV4_ONLY) {
spice_family = PF_INET;
}
@@ -4073,7 +4075,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s,
taTicket.expiration_time = now + lifetime;
}
if (passwd != NULL) {
- strncpy(taTicket.password, passwd, sizeof(taTicket.password)-1);
+ g_strlcpy(taTicket.password, passwd, sizeof(taTicket.password));
} else {
memset(taTicket.password, 0, sizeof(taTicket.password));
taTicket.expiration_time = 0;
@@ -4097,24 +4099,24 @@ SPICE_GNUC_VISIBLE int spice_server_set_tls(SpiceServer *s, int port,
memset(&ssl_parameters, 0, sizeof(ssl_parameters));
spice_secure_port = port;
- strncpy(ssl_parameters.ca_certificate_file, ca_cert_file,
- sizeof(ssl_parameters.ca_certificate_file)-1);
- strncpy(ssl_parameters.certs_file, certs_file,
- sizeof(ssl_parameters.certs_file)-1);
- strncpy(ssl_parameters.private_key_file, private_key_file,
- sizeof(ssl_parameters.private_key_file)-1);
+ g_strlcpy(ssl_parameters.ca_certificate_file, ca_cert_file,
+ sizeof(ssl_parameters.ca_certificate_file));
+ g_strlcpy(ssl_parameters.certs_file, certs_file,
+ sizeof(ssl_parameters.certs_file));
+ g_strlcpy(ssl_parameters.private_key_file, private_key_file,
+ sizeof(ssl_parameters.private_key_file));
if (key_passwd) {
- strncpy(ssl_parameters.keyfile_password, key_passwd,
- sizeof(ssl_parameters.keyfile_password)-1);
+ g_strlcpy(ssl_parameters.keyfile_password, key_passwd,
+ sizeof(ssl_parameters.keyfile_password));
}
if (ciphersuite) {
- strncpy(ssl_parameters.ciphersuite, ciphersuite,
- sizeof(ssl_parameters.ciphersuite)-1);
+ g_strlcpy(ssl_parameters.ciphersuite, ciphersuite,
+ sizeof(ssl_parameters.ciphersuite));
}
if (dh_key_file) {
- strncpy(ssl_parameters.dh_key_file, dh_key_file,
- sizeof(ssl_parameters.dh_key_file)-1);
+ g_strlcpy(ssl_parameters.dh_key_file, dh_key_file,
+ sizeof(ssl_parameters.dh_key_file));
}
return 0;
}
commit 55495a61bfd58332f6c8c0074d51b1bc649df5fa
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri Nov 23 16:41:48 2012 +0100
build: Use glib2
Now that QEMU depends on glib, it won't really hurt if we depend
on it as well, and we won't have to reinvent our own helpers.
diff --git a/configure.ac b/configure.ac
index a12e119..fc0216f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -238,6 +238,9 @@ if test "x$enable_smartcard" = "xyes"; then
fi
+PKG_CHECK_MODULES([GLIB2], [glib-2.0 >= 2.22])
+SPICE_REQUIRES+=" glib-2.0 >= 2.22"
+
PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.17.7)
AC_SUBST(PIXMAN_CFLAGS)
AC_SUBST(PIXMAN_LIBS)
diff --git a/server/Makefile.am b/server/Makefile.am
index b62d98c..4e5f18a 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -5,6 +5,7 @@ AM_CPPFLAGS = \
-DRED_STATISTICS \
$(CELT051_CFLAGS) \
$(COMMON_CFLAGS) \
+ $(GLIB2_CFLAGS) \
$(PIXMAN_CFLAGS) \
$(SASL_CFLAGS) \
$(SLIRP_CFLAGS) \
@@ -31,6 +32,7 @@ libspice_server_la_LIBADD = \
$(top_builddir)/spice-common/common/libspice-common-server.la \
$(CELT051_LIBS) \
$(GL_LIBS) \
+ $(GLIB2_LIBS) \
$(JPEG_LIBS) \
$(LIBRT) \
$(PIXMAN_LIBS) \
commit 7fe6b6303b83655d8975d72c65eec48024e90761
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri Nov 23 16:41:21 2012 +0100
Don't build client by default
It has been superseded by virt-viewer/remote-viewer
diff --git a/configure.ac b/configure.ac
index d02ea19..a12e119 100644
--- a/configure.ac
+++ b/configure.ac
@@ -150,7 +150,7 @@ fi
AC_ARG_ENABLE(client,
[ --enable-client Enable spice client],,
-[enable_client="yes"])
+[enable_client="no"])
AS_IF([test x"$enable_client" != "xno"], [enable_client="yes"])
AM_CONDITIONAL(SUPPORT_CLIENT, test "x$enable_client" = "xyes")
commit 5a31221252b6fe55189348d9433813c5f88f0c78
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri Nov 23 13:09:54 2012 +0100
Fail reds_init_socket when getaddrinfo fails
We currently output a warning when getaddrinfo fails, but then
we go on trying to use the information it couldn't read. Make
sure we bail out of reds_init_socket if getaddrinfo fails.
diff --git a/server/reds.c b/server/reds.c
index 7f729ca..9626318 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2973,6 +2973,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
if (rc != 0) {
spice_warning("getaddrinfo(%s,%s): %s", addr, port,
gai_strerror(rc));
+ return -1;
}
for (e = res; e != NULL; e = e->ai_next) {
commit 0b1d268011dc0b1518b61cb21073f21cdc53628f
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Fri Nov 23 12:59:39 2012 +0100
Make sure strncpy'ed string are 0-terminated
spice_server_set_ticket and spice_server_set_addr get (library)
user-provided strings as arguments, and copy them to fixed-size
buffers using strncpy. However, if these strings are too long,
the copied string will not be 0-terminated, which will cause issues
later. This commit copies one byte less than the size of the
destination buffer. In both cases, this buffer is a static global
variable, so its memory will be set to 0.
diff --git a/server/reds.c b/server/reds.c
index a896cf2..7f729ca 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3981,7 +3981,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_port(SpiceServer *s, int port)
SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *s, const char *addr, int flags)
{
spice_assert(reds == s);
- strncpy(spice_addr, addr, sizeof(spice_addr));
+ strncpy(spice_addr, addr, sizeof(spice_addr)-1);
if (flags & SPICE_ADDR_FLAG_IPV4_ONLY) {
spice_family = PF_INET;
}
@@ -4072,7 +4072,7 @@ SPICE_GNUC_VISIBLE int spice_server_set_ticket(SpiceServer *s,
taTicket.expiration_time = now + lifetime;
}
if (passwd != NULL) {
- strncpy(taTicket.password, passwd, sizeof(taTicket.password));
+ strncpy(taTicket.password, passwd, sizeof(taTicket.password)-1);
} else {
memset(taTicket.password, 0, sizeof(taTicket.password));
taTicket.expiration_time = 0;
More information about the Spice-commits
mailing list