From patchwork Thu Sep 7 08:45:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "plaisthos (Code Review)" X-Patchwork-Id: 3337 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7300:390:b0:d7:3b0f:3938 with SMTP id 16csp3129319dyq; Thu, 7 Sep 2023 01:45:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGr2OCamOb9rAR/rfuCPHtze3eX0Sz5RLqwVVoMQUM4NwGDX16CYTjRgWZc/XE8vq50F/5r X-Received: by 2002:a05:6a00:1bc7:b0:68e:4585:59ab with SMTP id o7-20020a056a001bc700b0068e458559abmr71744pfw.0.1694076351472; Thu, 07 Sep 2023 01:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694076351; cv=none; d=google.com; s=arc-20160816; b=pcZycErP9ra3xmSnHCNFyY3ttmy3NlzoAI4CvJZpgJObC+vOeTQv5dvOmxFPIP8jqp 5eT8ZpgcBVTXEAlXrz/Jlp/DEnqm6x2z2OmnWf3eCaYobEEjMmpv7wM7FMJRkzNJhmKs za1dtXBlheG++lJJ/Fn0yXr+ePVZ062/nZjhZfFf4xMTjfygzjng12FLUgmECN3pNeTG D+oEH7FHS6StOCAoC3MaHbIbBrF+0THzynd5mMXMzG/lv/iUE5r0igm0gjv0TxEzesnv 5tbVviKXRgd0IvrN8Dkf++dnuwr03DCFhhqeyiLDKPt9F3z4m2Ae9FsOVZ3kFZo8lDqH Y2Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :mime-version:message-id:references:auto-submitted:to:date:from :dkim-signature:dkim-signature:dkim-signature; bh=u/RatIt1rtA2eNZmEupUdZRbMMdb5yNoLUGd8poww0Q=; fh=GFP4qDxgyJ2WEPo/oeLZg3Mj4NqvY1j2nTvTt7psNwg=; b=PxqL6wv5RG/Jr0eMqbmy9kPh9pPJo7RKD1xow+0Cam00dRpENu/iFCbWXannmOgzXd iNKnYe2uo4P+WlUUnNHyveOc0NkKuUdjw1Q0ChRKDmVVr6tuuNIAkAdqxBso7ThXUnlQ Z8Y0Izrakkmhu7+9V3j1KMocvbLDY98iGSe+M5q8IYucG8pRq5w0O5j5qm9q25yv2rjS uLz17oT5ZXlvtmZ1l/Y+Vc58S1+KBK3A02ikZcc7LEc8btkEv9/B82lG0is6jeZEjwAN y07itmlp7bRBzI89uRpND+YJYZJxDhd6u03cl0iacjn1jSUzkEZi2NF55IBi8wksDHae eS8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=DYdLPnsK; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ZHNfVAve; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=SrXXHeHJ; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id bs184-20020a6328c1000000b005640118d203si12769291pgb.193.2023.09.07.01.45.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Sep 2023 01:45:51 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=DYdLPnsK; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=ZHNfVAve; dkim=neutral (body hash did not verify) header.i=@openvpn.net header.s=google header.b=SrXXHeHJ; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1qeAdd-0004sd-Co; Thu, 07 Sep 2023 08:45:22 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qeAdc-0004sX-4s for openvpn-devel@lists.sourceforge.net; Thu, 07 Sep 2023 08:45:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Reply-To:References:Subject:List-Unsubscribe:List-Id:Cc:To:Date: From:Sender:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8rnaD18pfX5BNOD1oxwggqJEjfAUM+DK78pnUdZ72TQ=; b=DYdLPnsKx/gaHgCn2jQ9borfTX WeKG89nBUCfyBP4TKI4y5e0CT7irMzdK1sh70iFGZZuzLP8XBg7j+HJTjXmNgpEBC28c64qWGTa61 m8uvvGPwqQLmQ47vqAOxVEY10BDlrCVH1PmOhd21tZud53zctYl1JW8sVUzh9qHnqq6g=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Reply-To: References:Subject:List-Unsubscribe:List-Id:Cc:To:Date:From:Sender:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:In-Reply-To:List-Help:List-Subscribe:List-Post: List-Owner:List-Archive; bh=8rnaD18pfX5BNOD1oxwggqJEjfAUM+DK78pnUdZ72TQ=; b=Z HNfVAveltKgVcnb/wKKz+P/Tp749TK4oM43wTEXzB2stNoj3RPQiFIf1WjUinkjw8S8evutR/mE/o zsV1N4hELZ/lQ+hHOL6R9n0pyOupXN+mJ8v2Pp5Dx8pHkwCxtYHGxZKgO9iWV+UqO8hjVQ5WJWk6K iNgOQd9QWYZPATJ0=; Received: from mail-wm1-f53.google.com ([209.85.128.53]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1qeAdV-00CBgr-3E for openvpn-devel@lists.sourceforge.net; Thu, 07 Sep 2023 08:45:21 +0000 Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-401da71b85eso7493395e9.1 for ; Thu, 07 Sep 2023 01:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvpn.net; s=google; t=1694076306; x=1694681106; darn=lists.sourceforge.net; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from:from:to:cc :subject:date:message-id:reply-to; bh=8rnaD18pfX5BNOD1oxwggqJEjfAUM+DK78pnUdZ72TQ=; b=SrXXHeHJg8kReAHageVUlX/j6EvscyzqimOZ67inQXxWI/47McXDfxx5xyPu6/PZMf 8eiJ+C6aYN63X/OBHI+BSKP70tf19i1zlhZAjI69YyjLYl+rC0xw9pmZ7ZPHfRV88TQW JN7GkObe8sPLLjAY7Frt5xqis4ZKrVM/5ATei7XrUbbuEfm3ZauXpg/u4vMYI3Xx72gV XuzU6ZbuTgcoziT/vePlhW6hK8vbebhw/aDDCKF4oloi7yNn3t9UfwaUZ8/u86i7wMv7 TsOqVcHEvwWJoN7NMi1ytA+c4GJT9wGzIuWyKc9rL14d156MYExnJ6tCFWuzVFBbeIPN xvtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694076306; x=1694681106; h=user-agent:content-disposition:content-transfer-encoding :mime-version:message-id:reply-to:references:subject :list-unsubscribe:list-id:auto-submitted:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8rnaD18pfX5BNOD1oxwggqJEjfAUM+DK78pnUdZ72TQ=; b=Kvjf+BP2E2fH0jmQURuVA3sRtpsKaJPstzWDVAJb+otRZQ7s5P0JMIH4XLDeurzjoE OMTuVzk2aiheUF1bvrh/wpdRyhAN/RdYO5Bn0GkAl1Cphea+Rug9EU+lyh8vqZlIRlY/ a3ZFzCOXOb7ahjEJzRYZFZShe69w8A6J9qXL0d4hDGGk/PFGHxpC6HphBIdhlRDaniJc JiyOeDLCID0kX/qZ/tPaIQnVYTElh74NaxonspdyTC3jd6GeHdIdjdck4f+kzWAbnp5V q0Izq4nx8ImudSULW7PeOFPRn1oozkOparUysXst2SIx+pJ4T6yu1Bln2ykfIwIl1efs uaow== X-Gm-Message-State: AOJu0YzpDHy9xi5PwrmMLM+FN+lBDFPd43c2jjPBqX5wLhyOFgeAdZ28 9TtJoKquCLYbYOL1JXuC6IGHwaX962Ziqfd/Wwo= X-Received: by 2002:a7b:cc8f:0:b0:401:7d3b:ccaf with SMTP id p15-20020a7bcc8f000000b004017d3bccafmr3837335wma.4.1694076306319; Thu, 07 Sep 2023 01:45:06 -0700 (PDT) Received: from gerrit.openvpn.in (ec2-18-159-0-78.eu-central-1.compute.amazonaws.com. [18.159.0.78]) by smtp.gmail.com with ESMTPSA id ay23-20020a5d6f17000000b003143add4396sm14117792wrb.22.2023.09.07.01.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 01:45:05 -0700 (PDT) From: "flichtenheld (Code Review)" X-Google-Original-From: "flichtenheld (Code Review)" X-Gerrit-PatchSet: 3 Date: Thu, 7 Sep 2023 08:45:05 +0000 To: plaisthos Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange X-Gerrit-Change-Id: I6818b153bdeb1eed65870af99b0531e95807fe0f X-Gerrit-Change-Number: 267 X-Gerrit-Project: openvpn X-Gerrit-ChangeURL: X-Gerrit-Commit: 155bfad9d2c25419a76256330335d659c68363fc References: Message-ID: MIME-Version: 1.0 User-Agent: Gerrit/3.8.0 X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit Content analysis details: (-0.2 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.128.53 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.128.53 listed in wl.mailspike.net] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.0 WEIRD_PORT URI: Uses non-standard port number for HTTP 0.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 T_KAM_HTML_FONT_INVALID Test for Invalidly Named or Formatted Colors in HTML X-Headers-End: 1qeAdV-00CBgr-3E Subject: [Openvpn-devel] [M] Change in openvpn[master]: Various fixes for -Wconversion errors X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: frank@lichtenheld.com, arne-openvpn@rfc2549.org, openvpn-devel@lists.sourceforge.net Cc: openvpn-devel Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1776367804189971374?= X-GMAIL-MSGID: =?utf-8?q?1776367804189971374?= Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/267?usp=email to review the following change. Change subject: Various fixes for -Wconversion errors ...................................................................... Various fixes for -Wconversion errors These are all fixes I considered "safe". They either - Have sufficient checks/shifts for a cast to be safe - Fix the type of a variable without requiring code changes - Are in non-critical unittest code v2: - add min_size instead of abusing min_int Change-Id: I6818b153bdeb1eed65870af99b0531e95807fe0f Signed-off-by: Frank Lichtenheld --- M src/openvpn/buffer.c M src/openvpn/crypto.c M src/openvpn/integer.h M src/openvpn/mss.c M src/openvpn/otime.c M src/openvpn/otime.h M src/openvpn/packet_id.c M src/openvpn/reliable.c M src/openvpn/socket.h M src/openvpn/tls_crypt.c M src/openvpn/xkey_helper.c M tests/unit_tests/openvpn/mock_get_random.c M tests/unit_tests/openvpn/test_crypto.c M tests/unit_tests/openvpn/test_packet_id.c M tests/unit_tests/openvpn/test_provider.c M tests/unit_tests/openvpn/test_tls_crypt.c 16 files changed, 50 insertions(+), 36 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/267/3 diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 24f1ef2..a32e7d2 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -352,7 +352,7 @@ return false; } - const int size = write(fd, BPTR(buf), BLEN(buf)); + const ssize_t size = write(fd, BPTR(buf), BLEN(buf)); if (size != BLEN(buf)) { msg(M_ERRNO, "Write error on file '%s'", filename); @@ -889,7 +889,7 @@ { break; } - line[n++] = c; + line[n++] = (char)c; } while (c); diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index a77b5a1..3152060 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -26,6 +26,8 @@ #include "config.h" #endif +#include + #include "syshead.h" #include "crypto.h" @@ -1275,8 +1277,8 @@ hex_byte[hb_index++] = c; if (hb_index == 2) { - unsigned int u; - ASSERT(sscanf((const char *)hex_byte, "%x", &u) == 1); + uint8_t u; + ASSERT(sscanf((const char *)hex_byte, "%" SCNx8, &u) == 1); *out++ = u; hb_index = 0; if (++count == keylen) @@ -1538,13 +1540,13 @@ ASSERT(cipher_kt_key_size(kt->cipher) <= MAX_CIPHER_KEY_LENGTH && md_kt_size(kt->digest) <= MAX_HMAC_KEY_LENGTH); - const uint8_t cipher_length = cipher_kt_key_size(kt->cipher); + const uint8_t cipher_length = (uint8_t)cipher_kt_key_size(kt->cipher); if (!buf_write(buf, &cipher_length, 1)) { return false; } - uint8_t hmac_length = md_kt_size(kt->digest); + uint8_t hmac_length = (uint8_t)md_kt_size(kt->digest); if (!buf_write(buf, &hmac_length, 1)) { diff --git a/src/openvpn/integer.h b/src/openvpn/integer.h index 215c159..30b9ecf 100644 --- a/src/openvpn/integer.h +++ b/src/openvpn/integer.h @@ -28,12 +28,12 @@ #ifndef htonll #define htonll(x) ((1==htonl(1)) ? (x) : \ - ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32)) + ((uint64_t)htonl((uint32_t)((x) & 0xFFFFFFFF)) << 32) | htonl((uint32_t)((x) >> 32))) #endif #ifndef ntohll #define ntohll(x) ((1==ntohl(1)) ? (x) : \ - ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32)) + ((uint64_t)ntohl((uint32_t)((x) & 0xFFFFFFFF)) << 32) | ntohl((uint32_t)((x) >> 32))) #endif /* @@ -65,6 +65,19 @@ } } +static inline size_t +min_size(size_t x, size_t y) +{ + if (x < y) + { + return x; + } + else + { + return y; + } +} + static inline int max_int(int x, int y) { diff --git a/src/openvpn/mss.c b/src/openvpn/mss.c index 816e65b..dbd3681 100644 --- a/src/openvpn/mss.c +++ b/src/openvpn/mss.c @@ -165,7 +165,7 @@ return; } - for (olen = hlen - sizeof(struct openvpn_tcphdr), + for (olen = hlen - (int) sizeof(struct openvpn_tcphdr), opt = (uint8_t *)(tc + 1); olen > 1; olen -= optlen, opt += optlen) diff --git a/src/openvpn/otime.c b/src/openvpn/otime.c index b28a90f..e751246 100644 --- a/src/openvpn/otime.c +++ b/src/openvpn/otime.c @@ -105,7 +105,7 @@ /* format a time_t as ascii, or use current time if 0 */ const char * -time_string(time_t t, int usec, bool show_usec, struct gc_arena *gc) +time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc) { struct buffer out = alloc_buf_gc(64, gc); struct timeval tv; diff --git a/src/openvpn/otime.h b/src/openvpn/otime.h index c27be89..d795c3c 100644 --- a/src/openvpn/otime.h +++ b/src/openvpn/otime.h @@ -43,7 +43,7 @@ bool frequency_limit_event_allowed(struct frequency_limit *f); /* format a time_t as ascii, or use current time if 0 */ -const char *time_string(time_t t, int usec, bool show_usec, struct gc_arena *gc); +const char *time_string(time_t t, long usec, bool show_usec, struct gc_arena *gc); /* struct timeval functions */ diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c index ef83248..3d6f3ee 100644 --- a/src/openvpn/packet_id.c +++ b/src/openvpn/packet_id.c @@ -588,14 +588,14 @@ } else { - diff = (int) prev_now - v; + diff = (int)(prev_now - v); if (diff < 0) { c = 'N'; } else if (diff < 10) { - c = '0' + diff; + c = (char)('0' + diff); } else { diff --git a/src/openvpn/reliable.c b/src/openvpn/reliable.c index e7d4d5f..0e26f98 100644 --- a/src/openvpn/reliable.c +++ b/src/openvpn/reliable.c @@ -257,8 +257,7 @@ struct buffer *buf, const struct session_id *sid, int max, bool prepend) { - int i, j; - uint8_t n; + int i, j, n; struct buffer sub; n = ack->len; @@ -270,9 +269,9 @@ copy_acks_to_mru(ack, ack_mru, n); /* Number of acks we can resend that still fit into the packet */ - uint8_t total_acks = min_int(max, ack_mru->len); + uint8_t total_acks = (uint8_t)min_int(max, ack_mru->len); - sub = buf_sub(buf, ACK_SIZE(total_acks), prepend); + sub = buf_sub(buf, (int)ACK_SIZE(total_acks), prepend); if (!BDEF(&sub)) { goto error; diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index bfc1253..a4acc5d 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -1181,7 +1181,7 @@ } /* write a TCP or UDP packet to link */ -static inline int +static inline size_t link_socket_write(struct link_socket *sock, struct buffer *buf, struct link_socket_actual *to) @@ -1198,7 +1198,7 @@ else { ASSERT(0); - return -1; /* NOTREACHED */ + return 0; /* NOTREACHED */ } } diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c index 975d31f..f0946cb 100644 --- a/src/openvpn/tls_crypt.c +++ b/src/openvpn/tls_crypt.c @@ -634,7 +634,7 @@ memcpy(&net_len, BEND(&wrapped_client_key) - sizeof(net_len), sizeof(net_len)); - size_t wkc_len = ntohs(net_len); + uint16_t wkc_len = ntohs(net_len); if (!buf_advance(&wrapped_client_key, BLEN(&wrapped_client_key) - wkc_len)) { msg(D_TLS_ERRORS, "Can not locate tls-crypt-v2 client key"); diff --git a/src/openvpn/xkey_helper.c b/src/openvpn/xkey_helper.c index 40839f2..fcf8c2e 100644 --- a/src/openvpn/xkey_helper.c +++ b/src/openvpn/xkey_helper.c @@ -292,7 +292,7 @@ * @return false on error, true on success * * On return enc_len is set to actual size of the result. - * enc is NULL or enc_len is not enough to store the result, it is set + * If enc is NULL or enc_len is not enough to store the result, it is set * to the required size and false is returned. */ bool @@ -337,8 +337,8 @@ MAKE_DI(sha512), MAKE_DI(sha224), MAKE_DI(sha512_224), MAKE_DI(sha512_256), {0, NULL, 0}}; - int out_len = 0; - int ret = 0; + size_t out_len = 0; + bool ret = false; int nid = OBJ_sn2nid(mdname); if (nid == NID_undef) @@ -354,7 +354,7 @@ if (tbslen != EVP_MD_size(EVP_get_digestbyname(mdname))) { - msg(M_WARN, "Error: encode_pkcs11: invalid input length <%d>", (int)tbslen); + msg(M_WARN, "Error: encode_pkcs11: invalid input length <%zu>", tbslen); goto done; } @@ -383,13 +383,13 @@ out_len = tbslen + di->sz; - if (enc && (out_len <= (int) *enc_len)) + if (enc && (out_len <= *enc_len)) { /* combine header and digest */ memcpy(enc, di->header, di->sz); memcpy(enc + di->sz, tbs, tbslen); - dmsg(D_XKEY, "encode_pkcs1: digest length = %d encoded length = %d", - (int) tbslen, (int) out_len); + dmsg(D_XKEY, "encode_pkcs1: digest length = %zu encoded length = %zu", + tbslen, out_len); ret = true; } diff --git a/tests/unit_tests/openvpn/mock_get_random.c b/tests/unit_tests/openvpn/mock_get_random.c index 787b5e3..dfc7287 100644 --- a/tests/unit_tests/openvpn/mock_get_random.c +++ b/tests/unit_tests/openvpn/mock_get_random.c @@ -41,6 +41,6 @@ { for (int i = 0; i < len; i++) { - output[i] = rand(); + output[i] = (uint8_t)rand(); } } diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/openvpn/test_crypto.c index 58eebc0..d765a4e 100644 --- a/tests/unit_tests/openvpn/test_crypto.c +++ b/tests/unit_tests/openvpn/test_crypto.c @@ -97,8 +97,8 @@ for (int i = 0; i < strlen(ciphername); i++) { - upper[i] = toupper(ciphername[i]); - lower[i] = tolower(ciphername[i]); + upper[i] = (char)toupper((unsigned char)ciphername[i]); + lower[i] = (char)tolower((unsigned char)ciphername[i]); if (rand() & 0x1) { random_case[i] = upper[i]; @@ -160,7 +160,7 @@ uint8_t out[32]; - ssl_tls1_PRF(seed, seed_len, secret, secret_len, out, sizeof(out)); + ssl_tls1_PRF(seed, (int)seed_len, secret, (int)secret_len, out, sizeof(out)); assert_memory_equal(good_prf, out, sizeof(out)); } diff --git a/tests/unit_tests/openvpn/test_packet_id.c b/tests/unit_tests/openvpn/test_packet_id.c index 90c67ac..c351858 100644 --- a/tests/unit_tests/openvpn/test_packet_id.c +++ b/tests/unit_tests/openvpn/test_packet_id.c @@ -94,7 +94,7 @@ assert(data->pis.id == 1); assert(data->pis.time == now); assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == htonl(now)); + assert_true(data->test_buf_data.buf_time == htonl((uint32_t)now)); } static void @@ -121,7 +121,7 @@ assert(data->pis.id == 1); assert(data->pis.time == now); assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == htonl(now)); + assert_true(data->test_buf_data.buf_time == htonl((uint32_t)now)); } static void @@ -152,7 +152,7 @@ assert(data->pis.id == 1); assert(data->pis.time == now); assert_true(data->test_buf_data.buf_id == htonl(1)); - assert_true(data->test_buf_data.buf_time == htonl(now)); + assert_true(data->test_buf_data.buf_time == htonl((uint32_t)now)); } static void diff --git a/tests/unit_tests/openvpn/test_provider.c b/tests/unit_tests/openvpn/test_provider.c index 335fca2..5e57f33 100644 --- a/tests/unit_tests/openvpn/test_provider.c +++ b/tests/unit_tests/openvpn/test_provider.c @@ -365,7 +365,7 @@ } /* return a predefined string as sig */ - memcpy(sig, good_sig, min_int(sizeof(good_sig), *siglen)); + memcpy(sig, good_sig, min_size(sizeof(good_sig), *siglen)); return 1; } diff --git a/tests/unit_tests/openvpn/test_tls_crypt.c b/tests/unit_tests/openvpn/test_tls_crypt.c index ed7c794..3b885ab 100644 --- a/tests/unit_tests/openvpn/test_tls_crypt.c +++ b/tests/unit_tests/openvpn/test_tls_crypt.c @@ -138,7 +138,7 @@ { for (int i = 0; i < len; i++) { - output[i] = i; + output[i] = (uint8_t)i; } return true; }