summaryrefslogtreecommitdiffstats
path: root/common/cmd_itest.c
diff options
context:
space:
mode:
authorFrans Meulenbroeks <fransmeulenbroeks@gmail.com>2010-02-22 22:49:06 +0100
committerWolfgang Denk <wd@denx.de>2010-02-24 00:09:45 +0100
commitf3651764e57e353251695691677bd95ba5a420bc (patch)
tree63884163fc463c1d6e9e0c706e30a1af05c143a9 /common/cmd_itest.c
parent0ad22703f06af5fe100cfe6f08b1f32ea89cd5b1 (diff)
downloadblackbird-obmc-uboot-f3651764e57e353251695691677bd95ba5a420bc.tar.gz
blackbird-obmc-uboot-f3651764e57e353251695691677bd95ba5a420bc.zip
cmd_itest.c: fix pointer dereferencing
fix pointer dereferencing if the size is .b and .w an 8 or 16 bit access is done. Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com> Acked-by: Detlev Zundel <dzu@denx.de>
Diffstat (limited to 'common/cmd_itest.c')
-rw-r--r--common/cmd_itest.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/common/cmd_itest.c b/common/cmd_itest.c
index 5b301bf5a5..58c5e7b3b5 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);
}
OpenPOWER on IntegriCloud