From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1dRcEo-0006y7-O4 for mharc-grub-devel@gnu.org; Sun, 02 Jul 2017 06:36:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dRcEm-0006xg-8F for grub-devel@gnu.org; Sun, 02 Jul 2017 06:36:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dRcEh-0007nj-BT for grub-devel@gnu.org; Sun, 02 Jul 2017 06:36:20 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:36288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dRcEh-0007kz-4u for grub-devel@gnu.org; Sun, 02 Jul 2017 06:36:15 -0400 Received: by mail-wm0-x244.google.com with SMTP id y5so15333166wmh.3 for ; Sun, 02 Jul 2017 03:36:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:reply-to:to:subject:date:user-agent:references:in-reply-to :mime-version:content-transfer-encoding:message-id; bh=RssJvgwYyP47hGbYxISVjhvy090N3cP2mGUMmGWzI2Q=; b=bI6tx2+jIOvaDULhqtH0FL45bVG4zCxbu2HQDK8XhjVDnPCCw+Jtra651oDLFc5YN7 SLZKGn392C9tFsPIAc5mlDlOA7FtbdRok+B0rhKUTxitNbrFKKVQlm1ZAibXkstN9xsx 2jq7trZntewIa8S9Wi37f54y8iXHkvpiSNSHW18ql8UQKuDQm0vJ8/T8RFwurn1Z2tPo VZQcBpT7MbBCG3ZPBD0jD/r4gofTvHCt6H/0mfUabMOungpLu39JpMXYvTqyfSfLzRZS ki1X8214T7BIVqII0/Y0YlrGJzk4B/OLYAFy87xvhdsAhgwNKmzvpMTYAsmevxT5qF2Z m5LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:reply-to:to:subject:date:user-agent :references:in-reply-to:mime-version:content-transfer-encoding :message-id; bh=RssJvgwYyP47hGbYxISVjhvy090N3cP2mGUMmGWzI2Q=; b=q6o66nbaopWFKyxGrFXngaVUBD/4iYAXuysna/jGlOGfkWJMOT/mly09kNRQxGJ7ti oJXqKTziJ5SEiX7VnBYy19/ZrvHsCchfBlm6UicYXHunDAjU+IdCjW3laQRcdur1JoJa EnJl841dJSl/7G/IjGcNEB1/73F9BuzuAvybf1SjS86+/CXR6vPscaZzW+81f+sZsGMA hrelVc0PwAW6JKzut6ApdQGe0XPaTBCNht/NNtAA1YiKiKxtkZavVVuxz/fzg/q5rqN2 KpWxSp8thA4IzPeYlgWUjQltVt8wtlCtuIVX7Ctmvj/rc5jdVtte2GOlz3fuAX4SXxLA Wo6Q== X-Gm-Message-State: AKS2vOwIr8OyTMrng1BvGn+7stFyCjSrQyU1X2YQm1O8Fzy16aHyx5ti Kpgund/LQ/0/52Rz X-Received: by 10.28.199.200 with SMTP id x191mr10941838wmf.94.1498991771910; Sun, 02 Jul 2017 03:36:11 -0700 (PDT) Received: from pali-latitude.localnet (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id f128sm1895006wmd.34.2017.07.02.03.36.10 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 02 Jul 2017 03:36:10 -0700 (PDT) From: Pali =?utf-8?q?Roh=C3=A1r?= Reply-To: Pali =?utf-8?q?Roh=C3=A1r?= , grub-devel@gnu.org To: grub-devel@gnu.org Subject: Re: [PATCH] * grub-core/fs/udf.c: Fix reading label, lvd.ident is dstring Date: Sun, 2 Jul 2017 12:36:09 +0200 User-Agent: KMail/1.13.7 (Linux/3.13.0-117-generic; KDE/4.14.2; x86_64; ; ) References: <1498134797-11903-1-git-send-email-pali.rohar@gmail.com> In-Reply-To: <1498134797-11903-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart8155266.xuc3PER1GH"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <201707021236.09793@pali> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Jul 2017 10:36:21 -0000 --nextPart8155266.xuc3PER1GH Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Thursday 22 June 2017 14:33:17 Pali Roh=C3=A1r wrote: > UDF dstring has stored length in the last byte of buffer. Therefore > last byte is not part of recorded characters. And empty string in > dstring is encoded as empty buffer, including first byte > (compression id). > --- > I'm not sure how Grub2 should handle empty label. Current patch set > empty buffer for empty label. But it is possible to ignore and do not > set label in this case at all. > --- Hi! Any comments on this patch? Specially how to deal with empty labels? > grub-core/fs/udf.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) >=20 > diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c > index 839bff8..e7a4d4e 100644 > --- a/grub-core/fs/udf.c > +++ b/grub-core/fs/udf.c > @@ -860,6 +860,25 @@ read_string (const grub_uint8_t *raw, > grub_size_t sz, char *outbuf) return outbuf; > } >=20 > +static char * > +read_dstring (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) > +{ > + grub_size_t len; > + > + if (raw[0] =3D=3D 0) > + { > + if (!outbuf) > + outbuf =3D grub_malloc (1); > + outbuf[0] =3D 0; > + return outbuf; > + } > + > + len =3D raw[sz - 1]; > + if (len > sz - 1) > + len =3D sz - 1; > + return read_string (raw, len, outbuf); > +} > + > static int > grub_udf_iterate_dir (grub_fshelp_node_t dir, > grub_fshelp_iterate_dir_hook_t hook, void *hook_data) > @@ -1197,7 +1216,7 @@ grub_udf_label (grub_device_t device, char > **label) >=20 > if (data) > { > - *label =3D read_string (data->lvd.ident, sizeof > (data->lvd.ident), 0); + *label =3D read_dstring > (data->lvd.ident, sizeof (data->lvd.ident), 0); grub_free (data); > } > else =2D-=20 Pali Roh=C3=A1r pali.rohar@gmail.com --nextPart8155266.xuc3PER1GH Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEABECAAYFAllYzJkACgkQi/DJPQPkQ1JBhQCgps7e+ok2ol7KsQnmJzm5Wff1 9n8AoLHdVBI0b1bpq+ZLMoOowjJPJ3T1 =kQAe -----END PGP SIGNATURE----- --nextPart8155266.xuc3PER1GH--