tlshd: fix max config file size comparison
PATCH 1/1 tlshd: fix max config file size comparison
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.
--- src/tlshd/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/tlshd/config.c +1 -1
@@ -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; }
Signature · 1 line
2.41.0
Quoted 28 lines · Jeff Layton
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_sizeis a signed value (off_t), butUINT_MAXis unsigned.Change it to compare against
INT_MAXinstead. 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 <[email protected]>Reported-by Petr Pisar <[email protected]>Signed-off-by Jeff Layton <[email protected]>---
src/tlshd/config.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)src/tlshd/config.c +0
-0
src/tlshd/config.c static bool tlshd_config_read_datum(const char *pathname, gnutls_datum_t *data, · line 158
Quoted 8 lines
src/tlshd/config.c +1
-1@@ -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