[前][次][番号順一覧][スレッド一覧]

ruby-changes:58224

From: Yusuke <ko1@a...>
Date: Sat, 12 Oct 2019 21:14:43 +0900 (JST)
Subject: [ruby-changes:58224] cb14c4a535 (master): missing/setproctitle.c: remove nonsense NULL check

https://git.ruby-lang.org/ruby.git/commit/?id=cb14c4a535

From cb14c4a535ca95bb87d47be284f447c9325733fd Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sat, 12 Oct 2019 21:10:49 +0900
Subject: missing/setproctitle.c: remove nonsense NULL check

If fmt is NULL, ptitle is uninitialized and used.
SETPROCTITLE(3bsd) says "If fmt is NULL, the process title is restored",
but looks like the feature is not implemented in missing/setproctitle.c.
At least the source code of ruby does not pass NULL to the function.
So I assume this function requires non-NULL fmt.

This issue was found by Coverity Scan.

diff --git a/missing/setproctitle.c b/missing/setproctitle.c
index 9fceeee..811829c 100644
--- a/missing/setproctitle.c
+++ b/missing/setproctitle.c
@@ -152,10 +152,9 @@ setproctitle(const char *fmt, ...) https://github.com/ruby/ruby/blob/trunk/missing/setproctitle.c#L152
 		return;
 #endif
 
+	/* fmt must be non-NULL */
 	va_start(ap, fmt);
-	if (fmt != NULL) {
-		vsnprintf(ptitle, sizeof(ptitle) , fmt, ap);
-	}
+	vsnprintf(ptitle, sizeof(ptitle), fmt, ap);
 	va_end(ap);
 
 #if SPT_TYPE == SPT_PSTAT
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]