]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd_itest.c: fix pointer dereferencing
authorFrans Meulenbroeks <fransmeulenbroeks@gmail.com>
Mon, 22 Feb 2010 21:49:06 +0000 (22:49 +0100)
committerWolfgang Denk <wd@denx.de>
Tue, 23 Feb 2010 23:09:45 +0000 (00:09 +0100)
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>
common/cmd_itest.c

index 5b301bf5a52821e91430ae458ae1d51e0ca2bb95..58c5e7b3b56d4a83d5757998520870c8efebf762 100644 (file)
@@ -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);
        }