From: Martin Schwenke Date: Mon, 24 Jun 2019 06:35:01 +0000 (+1000) Subject: ctdb-common: Fix signed/unsigned comparisons by casting X-Git-Tag: samba-4.11.0rc1~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ab5d5cece2b7d22cabfffd090cf3c675dca4af5;p=thirdparty%2Fsamba.git ctdb-common: Fix signed/unsigned comparisons by casting One case needs an extra variable declared. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c index 0f367c2100e..3f8fff925f0 100644 --- a/ctdb/common/ctdb_util.c +++ b/ctdb/common/ctdb_util.c @@ -111,7 +111,10 @@ bool ctdb_set_helper(const char *type, char *helper, size_t size, ("Unable to set %s - dir is NULL\n", type)); return false; } else { - if (snprintf(helper, size, "%s/%s", dir, file) >= size) { + int ret; + + ret = snprintf(helper, size, "%s/%s", dir, file); + if (ret < 0 || (size_t)ret >= size) { DEBUG(DEBUG_ERR, ("Unable to set %s - path too long\n", type)); return false; diff --git a/ctdb/common/event_script.c b/ctdb/common/event_script.c index 8bdfdd0b5ca..edd607f7a14 100644 --- a/ctdb/common/event_script.c +++ b/ctdb/common/event_script.c @@ -159,7 +159,7 @@ int event_script_chmod(const char *script_dir, script_file = script_name; } else { ret = snprintf(buf, sizeof(buf), "%s.script", script_name); - if (ret >= sizeof(buf)) { + if (ret < 0 || (size_t)ret >= sizeof(buf)) { return ENAMETOOLONG; } script_file = buf; @@ -196,7 +196,7 @@ int event_script_chmod(const char *script_dir, "%s/%s", script_dir, script_file); - if (ret >= sizeof(filename)) { + if (ret < 0 || (size_t)ret >= sizeof(filename)) { return ENAMETOOLONG; } diff --git a/ctdb/common/sock_io.c b/ctdb/common/sock_io.c index b5c9332526b..81e82c59ca0 100644 --- a/ctdb/common/sock_io.c +++ b/ctdb/common/sock_io.c @@ -198,7 +198,7 @@ static void sock_queue_handler(struct tevent_context *ev, goto fail; } - if (num_ready > queue->buflen - queue->end) { + if ((size_t)num_ready > queue->buflen - queue->end) { queue->buf = talloc_realloc_size(queue, queue->buf, queue->end + num_ready); if (queue->buf == NULL) {