* [PATCH] tlshd: fix max config file size comparison
@ 2023-06-20 17:20 Jeff Layton
2023-06-20 17:42 ` Chuck Lever III
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2023-06-20 17:20 UTC (permalink / raw)
To: chuck.lever; +Cc: kernel-tls-handshake, Steve Dickson, Petr Pisar
gcc throws a warning on 32-bit x86 because of signedness mismatch:
config.c:155:52: error: comparison of integer expressions of different signedness: '__off_t' {aka 'long int'} and 'unsigned int' [-Werror=sign-compare]
155 | if (statbuf.st_size < 0 || statbuf.st_size > UINT_MAX) {
| ^
st_size is a signed value (off_t), but UINT_MAX is unsigned.
Change it to compare against INT_MAX instead. This technically cuts the
max size of the config file in half to only 2GB, but I don't think we'll
miss it.
Cc: Steve Dickson <steved@redhat.com>
Reported-by: Petr Pisar <ppisar@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
src/tlshd/config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/tlshd/config.c b/src/tlshd/config.c
index 87cc4018733b..bdab98b9fba4 100644
--- a/src/tlshd/config.c
+++ b/src/tlshd/config.c
@@ -152,7 +152,7 @@ static bool tlshd_config_read_datum(const char *pathname, gnutls_datum_t *data,
tlshd_log_perror("stat");
goto out_close;
}
- if (statbuf.st_size < 0 || statbuf.st_size > UINT_MAX) {
+ if (statbuf.st_size < 0 || statbuf.st_size > INT_MAX) {
tlshd_log_error("Bad config file size: %lld", statbuf.st_size);
goto out_close;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tlshd: fix max config file size comparison
2023-06-20 17:20 [PATCH] tlshd: fix max config file size comparison Jeff Layton
@ 2023-06-20 17:42 ` Chuck Lever III
0 siblings, 0 replies; 2+ messages in thread
From: Chuck Lever III @ 2023-06-20 17:42 UTC (permalink / raw)
To: Jeff Layton; +Cc: kernel-tls-handshake, Steve Dickson, Petr Pisar
> On Jun 20, 2023, at 1:20 PM, Jeff Layton <jlayton@kernel.org> wrote:
>
> gcc throws a warning on 32-bit x86 because of signedness mismatch:
>
> config.c:155:52: error: comparison of integer expressions of different signedness: '__off_t' {aka 'long int'} and 'unsigned int' [-Werror=sign-compare]
> 155 | if (statbuf.st_size < 0 || statbuf.st_size > UINT_MAX) {
> | ^
>
> st_size is a signed value (off_t), but UINT_MAX is unsigned.
>
> Change it to compare against INT_MAX instead. This technically cuts the
> max size of the config file in half to only 2GB, but I don't think we'll
> miss it.
>
> Cc: Steve Dickson <steved@redhat.com>
> Reported-by: Petr Pisar <ppisar@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> src/tlshd/config.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/tlshd/config.c b/src/tlshd/config.c
> index 87cc4018733b..bdab98b9fba4 100644
> --- a/src/tlshd/config.c
> +++ b/src/tlshd/config.c
> @@ -152,7 +152,7 @@ static bool tlshd_config_read_datum(const char *pathname, gnutls_datum_t *data,
> tlshd_log_perror("stat");
> goto out_close;
> }
> - if (statbuf.st_size < 0 || statbuf.st_size > UINT_MAX) {
> + if (statbuf.st_size < 0 || statbuf.st_size > INT_MAX) {
> tlshd_log_error("Bad config file size: %lld", statbuf.st_size);
> goto out_close;
> }
Opened version ktls-utils-0.10-dev and applied this fix to oracle/ktls-utils.
--
Chuck Lever
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-20 17:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 17:20 [PATCH] tlshd: fix max config file size comparison Jeff Layton
2023-06-20 17:42 ` Chuck Lever III
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).