From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cjfez-0005yB-Ki for qemu-devel@nongnu.org; Fri, 03 Mar 2017 00:21:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cjfey-0007z4-OW for qemu-devel@nongnu.org; Fri, 03 Mar 2017 00:21:45 -0500 From: Markus Armbruster References: <1488491046-2549-1-git-send-email-armbru@redhat.com> <1488491046-2549-7-git-send-email-armbru@redhat.com> <73dfc384-d88c-0c5d-b8dc-70e193a78003@amsat.org> Date: Fri, 03 Mar 2017 06:21:39 +0100 In-Reply-To: <73dfc384-d88c-0c5d-b8dc-70e193a78003@amsat.org> ("Philippe =?utf-8?Q?Mathieu-Daud=C3=A9=22's?= message of "Thu, 2 Mar 2017 21:25:52 -0300") Message-ID: <871suf7x5o.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 06/15] sheepdog: Don't truncate long VDI name in _open(), _create() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: Eric Blake , qemu-devel@nongnu.org, kwolf@redhat.com, mitake.hitoshi@lab.ntt.co.jp, jcody@redhat.com, qemu-block@nongnu.org, namei.unix@gmail.com Philippe Mathieu-Daud=C3=A9 writes: > On 03/02/2017 08:32 PM, Eric Blake wrote: >> On 03/02/2017 03:43 PM, Markus Armbruster wrote: >>> sd_parse_uri() truncates long VDI names silently. Reject them >>> instead. >>> >>> Signed-off-by: Markus Armbruster >>> --- >>> block/sheepdog.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/block/sheepdog.c b/block/sheepdog.c >>> index deb110e..72a52a6 100644 >>> --- a/block/sheepdog.c >>> +++ b/block/sheepdog.c >>> @@ -985,7 +985,9 @@ static int sd_parse_uri(BDRVSheepdogState *s, const= char *filename, >>> ret =3D -EINVAL; >>> goto out; >>> } >>> - pstrcpy(vdi, SD_MAX_VDI_LEN, uri->path + 1); >>> + if (g_strlcpy(vdi, uri->path + 1, SD_MAX_VDI_LEN) >=3D SD_MAX_VDI_= LEN) { >>> + goto out; >>> + } >> >> Does this need to set ret? Maybe to -EINVAL? >> > > ups I missed that. what about -ENAMETOOLONG? > bdrv callers seem to only test for 'ret < 0'. The next patch gets rid of the error code in this function. >>> >>> qp =3D query_params_parse(uri->query); >>> if (qp->n > 1 || (s->is_unix && !qp->n) || (!s->is_unix && qp->n))= { >>> >>