From 2faffecc425e982d06704493670fe846402c98ed Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 18 Sep 2017 10:08:15 +0100 Subject: [PATCH] common/utils: Fix is_number("") to return FALSE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, it was possible to enter ‘ ’ (a space) at a number prompt, and it would be stripped, passed to is_number() (which would erroneously return TRUE), then passed to strtol() and the return value used unconditionally. Fix that by fixing is_number() to return FALSE for the empty string. Signed-off-by: Philip Withnall --- common/flatpak-utils.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index d3a665a9..45b9c48f 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -5320,6 +5320,9 @@ flatpak_yes_no_prompt (const char *prompt, ...) static gboolean is_number (const char *s) { + if (*s == '\0') + return FALSE; + while (*s != 0) { if (!g_ascii_isdigit (*s))