[PATCH] runsv: Fix incorrect descriptor treatment

Maks Mishin maks.mishinfz at gmail.com
Wed Aug 21 16:42:40 UTC 2024


Variable 'fd', which might receive a negative value
by calling function 'open_trunc_or_warn' at runsv.c:212, is used without
checking at runsv.c:244 by calling function 'write'.

Found by static analyzer Svace.

Signed-off-by: Maks Mishin <maks.mishinFZ at gmail.com>
---
 runit/runsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runit/runsv.c b/runit/runsv.c
index 20a445319..df7c59ac6 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -210,7 +210,7 @@ static void update_status(struct svdir *s)
 
 	/* stat */
 	fd = open_trunc_or_warn(fstatnew);
-	if (fd < -1)
+	if (fd < 0)
 		return;
 
 	{
-- 
2.30.2



More information about the busybox mailing list