public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes
Date: Fri, 11 Jan 2013 14:35:48 +0100	[thread overview]
Message-ID: <1357911348-28403-1-git-send-email-marex@denx.de> (raw)

In case a function argument is known/fixed size array in C, the argument is
still decoyed as pointer instead ( T f(U n[k]) ~= T fn(U *n) ) and therefore
calling sizeof on the function argument will result in the size of the pointer,
not the size of the array.

The VFAT code contains such a bug, this patch fixes it.

Reported-by: Aaron Williams <Aaron.Williams@cavium.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Tom Rini <tom.rini@gmail.com>
Cc: Aaron Williams <Aaron.Williams@cavium.com>
---
 fs/fat/fat.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 393c378..25d3318 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -569,9 +569,9 @@ static __u8 mkcksum(const char name[8], const char ext[3])
 
 	__u8 ret = 0;
 
-	for (i = 0; i < sizeof(name); i++)
+	for (i = 0; i < 8; i++)
 		ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + name[i];
-	for (i = 0; i < sizeof(ext); i++)
+	for (i = 0; i < 3; i++)
 		ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + ext[i];
 
 	return ret;
-- 
1.7.10.4

             reply	other threads:[~2013-01-11 13:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 13:35 Marek Vasut [this message]
2013-01-28 15:12 ` [U-Boot] [PATCH] vfat: Fix mkcksum argument sizes Michal Simek
2013-01-31 15:34 ` Joe Hershberger
2013-01-31 19:44 ` [U-Boot] " Tom Rini
2013-01-31 20:53   ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2013-01-29 16:00 [U-Boot] [PATCH] " Mats Kärrman

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=1357911348-28403-1-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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