From 2f46aec2be4b00fbf75cf22b5894f3eae9498944 Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Sat, 12 Oct 2024 20:47:39 +0400 Subject: [PATCH 1/2] Fix code scanning alert no. 1: Multiplication result converted to larger type Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- tpws/tpws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpws/tpws.c b/tpws/tpws.c index 3e49485..383edef 100644 --- a/tpws/tpws.c +++ b/tpws/tpws.c @@ -1132,7 +1132,7 @@ static bool set_ulimit(void) // additional 1/2 for unpaired remote legs sending buffers // 16 for listen_fd, epoll, hostlist, ... #ifdef SPLICE_PRESENT - fdmax = (params.nosplice ? 2 : (params.tamper && !params.tamper_lim ? 4 : 6)) * params.maxconn; + fdmax = (rlim_t)(params.nosplice ? 2 : (params.tamper && !params.tamper_lim ? 4 : 6)) * (rlim_t)params.maxconn; #else fdmax = 2 * params.maxconn; #endif From 81ae646c5a86e1f86c680ec095e536828a910e5c Mon Sep 17 00:00:00 2001 From: SashaXser <24498484+SashaXser@users.noreply.github.com> Date: Sat, 12 Oct 2024 20:48:24 +0400 Subject: [PATCH 2/2] Fix code scanning alert no. 2: Incorrect return-value check for a 'scanf'-like function Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- tpws/tpws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tpws/tpws.c b/tpws/tpws.c index 3e49485..ec79430 100644 --- a/tpws/tpws.c +++ b/tpws/tpws.c @@ -1087,7 +1087,7 @@ static bool read_system_maxfiles(rlim_t *maxfile) return false; n=fscanf(F,"%ju",&um); fclose(F); - if (!n) return false; + if (n != 1) return false; *maxfile = (rlim_t)um; return true; #elif defined(BSD)