Received: from list by lists.gnu.org with archive (Exim 4.71) id 1deymV-0007KX-6l for mharc-grub-devel@gnu.org; Tue, 08 Aug 2017 03:18:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1deymO-0007Ju-Je for grub-devel@gnu.org; Tue, 08 Aug 2017 03:18:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1deymJ-0000Dh-Hr for grub-devel@gnu.org; Tue, 08 Aug 2017 03:18:16 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:35145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1deymJ-0000DJ-A8 for grub-devel@gnu.org; Tue, 08 Aug 2017 03:18:11 -0400 Received: by mail-wr0-x229.google.com with SMTP id k71so9424316wrc.2 for ; Tue, 08 Aug 2017 00:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ndBuX0PG9IAzX5NctTc7MkJIK+jw99XFtdEzgK/TDLo=; b=m6aD+AbL9628Y58nI3PdJMnNXqRtrXvlOD7acEljaDkmqHAmFAQdxj5qZ+2WQHyjy5 Fq2HGQyVmSJAwH0mtF7dZx862hrXt/BlnyLvELiPC/Zejzp7RV03KbP6EIpYBZZa4h48 RES3z1HEf7IAH25xVRXVDpx9XyEpHhwpDmJWEEFdiNfRnWwHdgc4jN8tt02x/i5VThOu 4sjPR2ppJaKlHQN8M0EYGkGY+lRbw/YktFrIlYfY1O/LwhLWGl7GJlTcK+wUj3GbMIxS tNPncC77xI9WlIwI/Xekk0XlRK+bDJdF7LAUN3PHTn0KYqb+dwd7HEG45WLhhr+m5TQY x7FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=ndBuX0PG9IAzX5NctTc7MkJIK+jw99XFtdEzgK/TDLo=; b=QrDIxaOBgdPJmHerlEj5wWJ3tXS7564bE1UvB3VizuhMhRK4KmagfhLKbg97kXuhSL wpROjknBhtv81YW6CNGsbGibOE2qBJEoe81D+IVYLeiIQHUXc5qqYMmcsGH+GCpIuYqD XMF1URf5r1Gvwuubr9trLonnwv0rCgbYurh+MhTx8BYdfSgzCN7xUYCisBOLO4L4SV5K lgBBJSdqgiQfkr7A1We5bxPcrZdLnU3WhnVqGZIAwM3e6ZLujRiMSvII/lob8QnXNn8E xKmXxVld/uNzzS3w9cfWjRlyEvNTBNVfuJIZflKhcC1zUVLMlpXItOQ8uDfupGB7jpKV vqEQ== X-Gm-Message-State: AHYfb5izhMxDN6pHIqOWsbm9ls9m7kND+/M42VdKpUfAI0mM+aEVrXGl hIUBkvQIQG/pIPaT X-Received: by 10.223.139.219 with SMTP id w27mr1994968wra.146.1502176690049; Tue, 08 Aug 2017 00:18:10 -0700 (PDT) Received: from pali (atrey.karlin.mff.cuni.cz. [195.113.26.193]) by smtp.gmail.com with ESMTPSA id r195sm1221336wmg.40.2017.08.08.00.18.08 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 08 Aug 2017 00:18:09 -0700 (PDT) Date: Tue, 8 Aug 2017 09:18:08 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Vladimir 'phcoder' Serbinenko Cc: The development of GNU GRUB Subject: Re: [PATCH] * grub-core/fs/udf.c: Fix reading label, lvd.ident is dstring Message-ID: <20170808071808.GK1095@pali> References: <1498134797-11903-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23.1 (2014-03-12) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::229 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: Tue, 08 Aug 2017 07:18:21 -0000 Thanks a lot! On Monday 07 August 2017 15:40:15 Vladimir 'phcoder' Serbinenko wrote: > Committed with fixes and simplifications. The biggest problem was lack of > check whether grub_malloc succeeded > > Le Thu, Jun 22, 2017 à 2:34 PM, Pali Rohár a écrit : > > > 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. > > --- > > grub-core/fs/udf.c | 21 ++++++++++++++++++++- > > 1 file changed, 20 insertions(+), 1 deletion(-) > > > > 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; > > } > > > > +static char * > > +read_dstring (const grub_uint8_t *raw, grub_size_t sz, char *outbuf) > > +{ > > + grub_size_t len; > > + > > + if (raw[0] == 0) > > + { > > + if (!outbuf) > > + outbuf = grub_malloc (1); > > + outbuf[0] = 0; > > + return outbuf; > > + } > > + > > + len = raw[sz - 1]; > > + if (len > sz - 1) > > + len = 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) > > > > if (data) > > { > > - *label = read_string (data->lvd.ident, sizeof (data->lvd.ident), 0); > > + *label = read_dstring (data->lvd.ident, sizeof (data->lvd.ident), > > 0); > > grub_free (data); > > } > > else > > -- > > 1.7.9.5 > > > > > > _______________________________________________ > > Grub-devel mailing list > > Grub-devel@gnu.org > > https://lists.gnu.org/mailman/listinfo/grub-devel > > -- Pali Rohár pali.rohar@gmail.com