[PATCH 1/5] eal: add missing parameter check to rte_eal_alarm_set on Windows
Stephen Hemminger
stephen at networkplumber.org
Thu Aug 8 21:46:57 CEST 2024
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 at networkplumber.org>
---
lib/eal/windows/eal_alarm.c | 7 +++++++
1 file changed, 7 insertions(+)
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;
--
2.43.0
More information about the dev
mailing list