From mboxrd@z Thu Jan 1 00:00:00 1970 From: Detlev Zundel Date: Tue, 23 Feb 2010 12:37:38 +0100 Subject: [U-Boot] [PATCH 2/2] cmd_itest.c: fix pointer dereferencing In-Reply-To: <1266875346-17025-1-git-send-email-fransmeulenbroeks@gmail.com> (Frans Meulenbroeks's message of "Mon, 22 Feb 2010 22:49:06 +0100") References: <1266875346-17025-1-git-send-email-fransmeulenbroeks@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Frans, > fix pointer dereferencing > if the size is .b and .w an 8 or 16 bit access is done. > > Signed-off-by: Frans Meulenbroeks You could have included my previously given Acked-by. But anyway: Acked-by: Detlev Zundel > --- > common/cmd_itest.c | 9 +++++++-- > 1 files changed, 7 insertions(+), 2 deletions(-) > > diff --git a/common/cmd_itest.c b/common/cmd_itest.c > index 5b301bf..58c5e7b 100644 > --- a/common/cmd_itest.c > +++ b/common/cmd_itest.c > @@ -66,12 +66,17 @@ op_tbl_t op_table [] = { > > static long evalexp(char *s, int w) > { > - long l, *p; > + long l = 0; > + long *p; > > /* if the parameter starts with a * then assume is a pointer to the value we want */ > if (s[0] == '*') { > p = (long *)simple_strtoul(&s[1], NULL, 16); > - l = *p; > + switch (w) { > + case 1: return((long)(*(unsigned char *)p)); > + case 2: return((long)(*(unsigned short *)p)); > + case 4: return(*p); > + } > } else { > l = simple_strtoul(s, NULL, 16); > } -- It's like manually inflatable airbags -- people will never think to use it in time to actually get any help from it. -- Miles Bader in <20030607122005.GA1086@gnu.org> -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de