From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58894 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOGil-000880-Ob for qemu-devel@nongnu.org; Mon, 14 Jun 2010 16:57:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOGik-0007sD-3x for qemu-devel@nongnu.org; Mon, 14 Jun 2010 16:57:27 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:56474) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOGij-0007ly-Uw for qemu-devel@nongnu.org; Mon, 14 Jun 2010 16:57:26 -0400 Received: by mail-iw0-f173.google.com with SMTP id 10so4582648iwn.4 for ; Mon, 14 Jun 2010 13:57:25 -0700 (PDT) Message-ID: <4C1697B4.3030402@codemonkey.ws> Date: Mon, 14 Jun 2010 15:57:24 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] qemu-option: Reject anti-social IDs References: <1275998066-2796-1-git-send-email-armbru@redhat.com> In-Reply-To: <1275998066-2796-1-git-send-email-armbru@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, kraxel@redhat.com On 06/08/2010 06:54 AM, Markus Armbruster wrote: > Restrict IDs to letters, digits, '-', '.', '_', starting with a > letter. > > This takes care of '/' in qdev IDs breaking qbus_find(). > > Signed-off-by: Markus Armbruster > Applied. Thanks. Regards, Anthony Liguori > --- > qemu-option.c | 20 ++++++++++++++++++++ > 1 files changed, 20 insertions(+), 0 deletions(-) > > diff --git a/qemu-option.c b/qemu-option.c > index acd74f9..74fb882 100644 > --- a/qemu-option.c > +++ b/qemu-option.c > @@ -672,11 +672,31 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id) > return NULL; > } > > +static int id_wellformed(const char *id) > +{ > + int i; > + > + if (!qemu_isalpha(id[0])) { > + return 0; > + } > + for (i = 1; id[i]; i++) { > + if (!qemu_isalnum(id[i])&& !strchr("-._", id[i])) { > + return 0; > + } > + } > + return 1; > +} > + > QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists) > { > QemuOpts *opts = NULL; > > if (id) { > + if (!id_wellformed(id)) { > + qerror_report(QERR_INVALID_PARAMETER_VALUE, "id", "an identifier"); > + error_printf_unless_qmp("Identifiers consist of letters, digits, '-', '.', '_', starting with a letter.\n"); > + return NULL; > + } > opts = qemu_opts_find(list, id); > if (opts != NULL) { > if (fail_if_exists) { >