From ab3f09dfb0ae5e3a709975925b2d202f2a7b59e8 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 1 Apr 2011 00:30:40 -0700 Subject: [PATCH] Fixed integer overflow in guac_sleep. --- libguac/src/protocol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index bcd175d6..198d4623 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -170,6 +170,10 @@ int guac_send_args(GUACIO* io, const char** args) { int i; + /* Handle protocols with no args */ + if (args[0] == NULL) + return guac_write_string(io, "args;"); + if (guac_write_string(io, "args:")) return -1; for (i=0; args[i] != NULL; i++) { @@ -530,8 +534,8 @@ void guac_sleep(int millis) { #ifdef HAVE_NANOSLEEP struct timespec sleep_period; - sleep_period.tv_sec = 0; - sleep_period.tv_nsec = millis * 1000000L; + sleep_period.tv_sec = millis / 1000; + sleep_period.tv_nsec = (millis % 1000) * 1000000L; nanosleep(&sleep_period, NULL); #elif defined(__MINGW32__)