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.
This commit is contained in:
Mario Limonciello 2020-04-20 15:40:11 -05:00 committed by Richard Hughes
parent bc3c241f91
commit c6009f59fe
2 changed files with 21 additions and 0 deletions

View File

@ -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);
}

View File

@ -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);
}