From 33948929dff5f59ce70a320efee27f55479885af Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 22 Jun 2020 13:10:35 +0100 Subject: [PATCH] =?UTF-8?q?gspawn:=20Don=E2=80=99t=20use=20g=5Fascii=5Fisd?= =?UTF-8?q?igit()=20in=20async-signal-safe=20context?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While `g_ascii_isdigit()` *is* currently async-signal-safe, it’s going to be hard to remember to keep it that way if the implementation changes in future. It seems more robust to just reimplement it here, given that it’s not much code. See `man 7 signal-safety`. Signed-off-by: Philip Withnall Helps: #2140 --- glib/gspawn.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/glib/gspawn.c b/glib/gspawn.c index 09793fe1c..458f6c8a2 100644 --- a/glib/gspawn.c +++ b/glib/gspawn.c @@ -1185,8 +1185,7 @@ filename_to_fd (const char *p) while ((c = *p++) != '\0') { - /* FIXME: g_ascii_isdigit() is not necessarily async-signal-safe. */ - if (!g_ascii_isdigit (c)) + if (c < '0' || c > '9') return -1; c -= '0';