A followup to: https://sourceware.org/pipermail/cygwin-patches/2025q2/013678.html
-- Regards, Christian
From bbdaf4cfb487b7d134b5fda00447f77b6d0cfd27 Mon Sep 17 00:00:00 2001 From: Christian Franke <christian.fra...@t-online.de> Date: Mon, 28 Apr 2025 17:27:28 +0200 Subject: [PATCH] Cygwin: clock_settime: fail with EINVAL if tv_nsec is negative Addresses: https://sourceware.org/pipermail/cygwin-patches/2025q2/013665.html Fixes: 6758d2a3aae6 ("(clock_settime): New function.") Signed-off-by: Christian Franke <christian.fra...@t-online.de> --- winsup/cygwin/times.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index a89980d08..3c3ba9236 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -490,7 +490,8 @@ clock_settime (clockid_t clk_id, const struct timespec *tp) return -1; } - if (clk_id != CLOCK_REALTIME_COARSE && clk_id != CLOCK_REALTIME) + if ((clk_id != CLOCK_REALTIME_COARSE && clk_id != CLOCK_REALTIME) + || tp->tv_nsec < 0) /* Otherwise -999...-1 would be accepted */ { set_errno (EINVAL); return -1; -- 2.45.1