From: Davidlohr Bueso <davidlohr@hp.com>
To: amiettinen@nvidia.com
Cc: axboe@kernel.dk, akpm@linux-foundation.org,
matt.fleming@intel.com, kzak@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs: partitions: efi: Fix bound check
Date: Tue, 19 Nov 2013 17:06:31 -0800 [thread overview]
Message-ID: <1384909591.2588.32.camel@buesod1.americas.hpqcorp.net> (raw)
In-Reply-To: <20131115.191422.1787913255098350249.apm@brigitte.kvy.fi>
On Fri, 2013-11-15 at 19:14 +0200, Antti P Miettinen wrote:
> Use ARRAY_SIZE instead of sizeof to get proper max for label
> length.
>
> Signed-off-by: Antti P Miettinen <amiettinen@nvidia.com>
> Reviewed-by: Hiroshi Doyu <hdoyu@nvidia.com>
> Tested-by: Hiroshi Doyu <hdoyu@nvidia.com>
I haven't tested the patch, but using ARRAY_SIZE for fields defined as
arrays does make more sense than sizeof.
Acked-by: Davidlohr Bueso <davidlohr@hp.com>
> ---
> block/partitions/efi.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> index a8287b4..dc51f46 100644
> --- a/block/partitions/efi.c
> +++ b/block/partitions/efi.c
> @@ -96,6 +96,7 @@
> * - Code works, detects all the partitions.
> *
> ************************************************************/
> +#include <linux/kernel.h>
> #include <linux/crc32.h>
> #include <linux/ctype.h>
> #include <linux/math64.h>
> @@ -715,8 +716,8 @@ int efi_partition(struct parsed_partitions *state)
> efi_guid_unparse(&ptes[i].unique_partition_guid, info->uuid);
>
> /* Naively convert UTF16-LE to 7 bits. */
> - label_max = min(sizeof(info->volname) - 1,
> - sizeof(ptes[i].partition_name));
> + label_max = min(ARRAY_SIZE(info->volname) - 1,
> + ARRAY_SIZE(ptes[i].partition_name));
> info->volname[label_max] = 0;
> while (label_count < label_max) {
> u8 c = ptes[i].partition_name[label_count] & 0xff;
prev parent reply other threads:[~2013-11-20 1:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-15 17:14 Antti P Miettinen
2013-11-20 0:04 ` Andrew Morton
2013-11-20 7:18 ` Antti Miettinen
2013-11-20 7:36 ` Hiroshi Doyu
2013-11-20 17:46 ` Davidlohr Bueso
2013-11-20 1:06 ` Davidlohr Bueso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1384909591.2588.32.camel@buesod1.americas.hpqcorp.net \
--to=davidlohr@hp.com \
--cc=akpm@linux-foundation.org \
--cc=amiettinen@nvidia.com \
--cc=axboe@kernel.dk \
--cc=kzak@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®