[1/5] eal: add missing parameter check to rte_eal_alarm_set on Windows

Message ID 20240808194756.167664-2-stephen@networkplumber.org (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series alarm related patches |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Stephen Hemminger Aug. 8, 2024, 7:46 p.m. UTC
Both Linux and FreeBSD, check parameters to rte_eal_alarm_set,
but Windows missed this. And the test was "fixed" instead.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/windows/eal_alarm.c | 7 +++++++
 1 file changed, 7 insertions(+)
  

Patch

diff --git a/lib/eal/windows/eal_alarm.c b/lib/eal/windows/eal_alarm.c
index 052af4b21b..09a02a1cbf 100644
--- a/lib/eal/windows/eal_alarm.c
+++ b/lib/eal/windows/eal_alarm.c
@@ -92,6 +92,13 @@  rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 	LARGE_INTEGER deadline;
 	int ret;
 
+	/* Check parameters, including that us won't cause a uint64_t overflow */
+	if (us < 1 || us > (UINT64_MAX - US_PER_S)) {
+		EAL_LOG(ERR, "Invalid alarm interval");
+		ret = -EINVAL;
+		goto exit;
+	}
+
 	if (cb_fn == NULL) {
 		EAL_LOG(ERR, "NULL callback");
 		ret = -EINVAL;