public inbox for kernel-tls-handshake@lists.linux.dev
 help / color / mirror / Atom feed
* [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

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