From: Brian Fukano <bfukano@gmail.com>
To: bfukano@gmail.com, connman@lists.linux.dev
Subject: [PATCH] dnsproxy: fix signedness warnings
Date: Fri, 9 Feb 2024 10:01:48 -0800 [thread overview]
Message-ID: <20240209180148.19443-1-bfukano@gmail.com> (raw)
This fixes the signdness warnings in dnsproxy.c
---
src/dnsproxy.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index d4242560..72e77f96 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -436,7 +436,7 @@ static void update_cached_ttl(unsigned char *ptr, int len, int new_ttl)
ptr += DNS_HEADER_SIZE;
len -= DNS_HEADER_SIZE;
- if (len < DNS_QUESTION_SIZE + 1)
+ if (len < 0 || (unsigned int)len < DNS_QUESTION_SIZE + 1)
return;
/* skip the query, which is a name and a struct domain_question */
@@ -459,7 +459,7 @@ static void update_cached_ttl(unsigned char *ptr, int len, int new_ttl)
break;
rr = (void*)ptr;
- if (len < sizeof(*rr))
+ if ((unsigned int)len < sizeof(*rr))
/* incomplete record */
break;
@@ -520,7 +520,7 @@ static void send_cached_response(int sk, const unsigned char *ptr, size_t len,
connman_error("Cannot send cached DNS response: %s",
strerror(errno));
}
- else if (err != len || dns_len != (len - offset))
+ else if ((unsigned int)err != len || dns_len != (len - offset))
debug("Packet length mismatch, sent %d wanted %zd dns %zd",
err, len, dns_len);
}
@@ -656,7 +656,7 @@ static int append_data(unsigned char *buf, size_t size, const char *data)
while (true) {
const char *dot = strchr(data, '.');
- len = dot ? dot - data : strlen(data);
+ len = dot ? (unsigned int)(dot - data) : strlen(data);
if (len == 0)
break;
@@ -1063,7 +1063,7 @@ static int parse_response(const unsigned char *buf, size_t buflen,
qlen = strlen(question);
ptr += qlen + 1; /* skip \0 */
- if ((eptr - ptr) < DNS_QUESTION_SIZE)
+ if ((unsigned int)(eptr - ptr) < DNS_QUESTION_SIZE)
return -EINVAL;
q = (void *) ptr;
@@ -2031,7 +2031,7 @@ static int dns_reply_fixup_domains(
const char *domain;
/* full header plus at least one byte for the hostname length */
- if (reply_len < header_len + 1)
+ if (reply_len < (unsigned int)(header_len + 1))
return -EINVAL;
section_counts[0] = hdr->ancount;
@@ -2521,7 +2521,7 @@ hangup:
connman_error("DNS proxy error %s",
strerror(errno));
goto hangup;
- } else if (bytes_recv < sizeof(reply_len))
+ } else if ((unsigned int)bytes_recv < sizeof(reply_len))
return TRUE;
/* the header contains the length of the message
--
2.34.1
next reply other threads:[~2024-02-09 18:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 18:01 Brian Fukano [this message]
2024-02-13 8:42 ` [PATCH] dnsproxy: fix signedness warnings Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240209180148.19443-1-bfukano@gmail.com \
--to=bfukano@gmail.com \
--cc=connman@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox