Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MX1mC-0002Up-7f for qemu-devel@nongnu.org; Fri, 31 Jul 2009 19:44:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MX1m7-0002Pi-Br for qemu-devel@nongnu.org; Fri, 31 Jul 2009 19:44:39 -0400 Received: from [199.232.76.173] (port=38792 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MX1m6-0002Pa-QB for qemu-devel@nongnu.org; Fri, 31 Jul 2009 19:44:34 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35810) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MX1m6-00013c-0V for qemu-devel@nongnu.org; Fri, 31 Jul 2009 19:44:34 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6VNiHv2008145 for ; Fri, 31 Jul 2009 19:44:22 -0400 Subject: Re: [Qemu-devel] [PATCH 1/2] qdev: factor out qdev_print_devinfo. References: <1248865944-15937-1-git-send-email-kraxel@redhat.com> From: Markus Armbruster Date: Sat, 01 Aug 2009 01:44:14 +0200 In-Reply-To: <1248865944-15937-1-git-send-email-kraxel@redhat.com> (Gerd Hoffmann's message of "Wed\, 29 Jul 2009 13\:12\:23 +0200") Message-ID: <87zlak7701.fsf@pike.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org Gerd Hoffmann writes: > Signed-off-by: Gerd Hoffmann > --- > hw/qdev.c | 19 ++++++++++++++++++- > 1 files changed, 18 insertions(+), 1 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index 479eb72..6f05232 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -105,6 +105,21 @@ DeviceState *qdev_create(BusState *bus, const char *name) > return dev; > } > > +static int qdev_print_devinfo(DeviceInfo *info, char *dest, int len) > +{ > + int pos = 0; > + > + pos += snprintf(dest+pos, len-pos, "name \"%s\", bus %s", > + info->name, info->bus_info->name); > + if (info->alias) > + pos += snprintf(dest+pos, len-pos, ", alias \"%s\"", info->alias); > + if (info->desc) > + pos += snprintf(dest+pos, len-pos, ", desc \"%s\"", info->desc); > + if (info->no_user) > + pos += snprintf(dest+pos, len-pos, ", no-user"); > + return pos; > +} > + Isn't len-pos vulnerable to underflow here? The formal parameter type is size_t... [...]