aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilad Arnold <garnold@google.com>2015-08-24 18:06:33 -0700
committerGilad Arnold <garnold@google.com>2015-08-25 19:49:24 -0700
commitf162a324dd2c6bd9aa08741fc623d134eecbc2cf (patch)
tree636413cc3bda2008bf51099711edda32ef004dac
parent47194ce69c05cd9bb636e13810afec732ff4067b (diff)
downloadtlsdate-f162a324dd2c6bd9aa08741fc623d134eecbc2cf.tar.gz
Stop comparing signed and unsigned integers.
Also fixes an implicit casting to unsigned of sprintf() return value. Bug: 22373707 Change-Id: I5f04f0abd0ecd2594e204dcfe70e161db94484d6
-rw-r--r--src/platform-cros.c10
-rw-r--r--src/tlsdate-helper.c6
-rw-r--r--src/tlsdated.c5
3 files changed, 11 insertions, 10 deletions
diff --git a/src/platform-cros.c b/src/platform-cros.c
index 5a9d7ab..b9a148b 100644
--- a/src/platform-cros.c
+++ b/src/platform-cros.c
@@ -130,7 +130,7 @@ void
canonicalize_pac (const char *pac_fmt, char *proxy_url, size_t len)
{
size_t type_len;
- size_t copied = 0;
+ int copied = 0;
const char *space;
/* host[255]:port[6]\0 */
char hostport[6 + 255 + 2];
@@ -172,7 +172,7 @@ canonicalize_pac (const char *pac_fmt, char *proxy_url, size_t len)
{
error ("pac_fmt unmatched: '%s' %zu", pac_fmt, type_len);
}
- if (copied >= len)
+ if (copied < 0 || ((size_t) copied) >= len)
{
error ("canonicalize_pac: truncation '%s'", proxy_url);
proxy_url[0] = '\0';
@@ -306,7 +306,7 @@ handle_proxy_change (DBusConnection *connection,
/* Make sure this was the resolution we asked for */
url_len = snprintf (time_host, sizeof (time_host), "https://%s:%s",
src->host, src->port);
- if (url_len >= sizeof (time_host))
+ if (url_len < 0 || ((size_t) url_len) >= sizeof (time_host))
{
error ("[event:cros:%s]: current source url is too long",
__func__);
@@ -477,7 +477,7 @@ add_match (DBusConnection *conn, const char *interface, const char *member,
len = snprintf (match, sizeof (match), kMatchNoArgFormat,
interface, member);
}
- if (len >= sizeof (match) || len < 0)
+ if (len < 0 || ((size_t) len) >= sizeof (match))
{
error ("[dbus] match truncated for '%s,%s'", interface, member);
return 1;
@@ -515,7 +515,7 @@ new_resolver_message(const struct source *src)
/* Build the time_host */
url_len = snprintf (time_host, sizeof (time_host), "https://%s:%s",
src->host, src->port);
- if (url_len >= sizeof (time_host))
+ if (url_len < 0 || ((size_t) url_len) >= sizeof (time_host))
{
fatal ("[cros] source %d url is too long! (%d)", src->id, url_len);
}
diff --git a/src/tlsdate-helper.c b/src/tlsdate-helper.c
index 877c67e..7f7130e 100644
--- a/src/tlsdate-helper.c
+++ b/src/tlsdate-helper.c
@@ -305,7 +305,7 @@ handle_date_line(const char *dateline, uint32_t *result)
tm.tm_sec = sec;
t = timegm(&tm);
- if (t > 0xffffffff || t < 0)
+ if (t > ((time_t) 0xffffffff) || t < 0)
return -1;
*result = (uint32_t) t;
@@ -318,7 +318,7 @@ read_http_date_from_bio(BIO *bio, uint32_t *result)
{
int n;
char buf[MAX_HTTP_HEADERS_SIZE];
- int buf_len=0;
+ size_t buf_len=0;
char *dateline, *endofline;
while (buf_len < sizeof(buf)-1) {
@@ -712,7 +712,7 @@ check_san (SSL *ssl, const char *hostname)
if (method->i2v)
{
val = method->i2v(method, extvalstr, NULL);
- for (j = 0; j < sk_CONF_VALUE_num(val); ++j)
+ for (j = 0; ((size_t) j) < sk_CONF_VALUE_num(val); ++j)
{
nval = sk_CONF_VALUE_value(val, j);
if ((!strcasecmp(nval->name, "DNS") &&
diff --git a/src/tlsdated.c b/src/tlsdated.c
index 0165b58..a4af628 100644
--- a/src/tlsdated.c
+++ b/src/tlsdated.c
@@ -394,8 +394,9 @@ check_conf (struct state *state)
fatal ("-d argument must be nonzero");
if (!opts->steady_state_interval)
fatal ("-a argument must be nonzero");
- if (snprintf (state->timestamp_path, sizeof (state->timestamp_path),
- "%s/timestamp", opts->base_path) >= sizeof (state->timestamp_path))
+ int ret = snprintf (state->timestamp_path, sizeof (state->timestamp_path),
+ "%s/timestamp", opts->base_path);
+ if (ret < 0 || ((size_t) ret) >= sizeof (state->timestamp_path))
fatal ("supplied base path is too long: '%s'", opts->base_path);
if (opts->jitter >= opts->steady_state_interval)
fatal ("jitter must be less than steady state interval (%d >= %d)",