Received: from eggs.gnu.org ([208.118.235.92]:60401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScXqk-0005FH-Ke for qemu-devel@nongnu.org; Thu, 07 Jun 2012 04:13:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScXqe-0003sV-7f for qemu-devel@nongnu.org; Thu, 07 Jun 2012 04:13:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScXqd-0003sO-Vz for qemu-devel@nongnu.org; Thu, 07 Jun 2012 04:13:40 -0400 From: Markus Armbruster References: <1338900668-6093-1-git-send-email-armbru@redhat.com> <1338900668-6093-3-git-send-email-armbru@redhat.com> Date: Thu, 07 Jun 2012 10:13:32 +0200 In-Reply-To: (Peter Maydell's message of "Thu, 7 Jun 2012 01:07:45 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/2] xen: Don't peek behind the BlockDriverState abstraction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefano.stabellini@eu.citrix.com Peter Maydell writes: > On 6 June 2012 13:55, Markus Armbruster wrote: >> Peter Maydell writes: >> >>> On 5 June 2012 13:51, Markus Armbruster wrote: >>>> @@ -554,6 +553,7 @@ static int blk_init(struct XenDevice *xendev) >>>> =C2=A0{ >>>> =C2=A0 =C2=A0 struct XenBlkDev *blkdev =3D container_of(xendev, struct= XenBlkDev, xendev); >>>> =C2=A0 =C2=A0 int index, qflags, info =3D 0; >>>> + =C2=A0 =C2=A0char fmt_name[128]; >>> >>> Fixed length array with a hardcoded magic number size ? >>> If the block layer guarantees that format names are going to be >>> less than 128 bytes it ought to provide a suitable #define for >>> people to set array sizes to... >> >> Maybe it should, but it doesn't. =C2=A0Does it really matter in this >> particular case? =C2=A0If somebody insists on giving his driver a name l= onger >> than 127 characters, we'll silently log it truncated, that's all. > > I think it matters in the general case, yours is just the first > usage of this API which has caught my attention. We should fix > the API before adding more uses of it (at the moment it seems to > be only used in two places). What kind of fix do you have in mind? > Alternatively, we could have the function return a const char* rather > than taking a buffer to be filled in. Trades the theoretical string truncation problem for a theoretical dangling pointer problem.