From c6009f59fe149b91550f32e6da12753336645338 Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Mon, 20 Apr 2020 15:40:11 -0500 Subject: [PATCH] trivial: fu-util/fu-tool: check for '-' in arguments Make sure if something doesn't look like a duck that it's not a duck. --- src/fu-tool.c | 11 +++++++++++ src/fu-util.c | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/fu-tool.c b/src/fu-tool.c index ff9d53e86..fbffb97d2 100644 --- a/src/fu-tool.c +++ b/src/fu-tool.c @@ -645,6 +645,17 @@ fu_util_get_device (FuUtilPrivate *priv, const gchar *id, GError **error) return NULL; return fu_util_prompt_for_device (priv, devices, error); } + + /* did this look like a GUID? */ + for (guint i = 0; id[i] != '\0'; i++) { + if (id[i] == '-') { + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_ARGS, + "Invalid arguments"); + return FALSE; + } + } return fu_engine_get_device (priv->engine, id, error); } diff --git a/src/fu-util.c b/src/fu-util.c index 186c8e9e0..733dda7a0 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -1040,6 +1040,16 @@ fu_util_get_device_by_id (FuUtilPrivate *priv, const gchar *id, GError **error) return NULL; return fu_util_prompt_for_device (priv, devices, error); } + /* did this look like a GUID? */ + for (guint i = 0; id[i] != '\0'; i++) { + if (id[i] == '-') { + g_set_error_literal (error, + FWUPD_ERROR, + FWUPD_ERROR_INVALID_ARGS, + "Invalid arguments"); + return FALSE; + } + } return fwupd_client_get_device_by_id (priv->client, id, NULL, error); }