]> Zhao Yanbai Git Server - minix.git/commitdiff
Range-check values building mbdev in boot monitor
authorAntoine Leca <Antoine.Leca.1@gmail.com>
Wed, 31 Aug 2011 11:54:31 +0000 (13:54 +0200)
committerArun Thomas <arun@minix3.org>
Wed, 31 Aug 2011 13:04:38 +0000 (15:04 +0200)
boot/boot/boot.c

index 402a4b4c0bfae77c6a5165e6fddb616b94f9b7f5..4cf600dfeb23dc7e662e86a2d1d2e0ae7f66a8ba 100644 (file)
@@ -1228,9 +1228,9 @@ dev_t name2dev(char *name)
                }
        }
 
-       mbdev = (u32_t)tmpdev.device << 24
-           | (u32_t)tmpdev.primary << 16
-           | (u32_t)tmpdev.secondary << 8
+       mbdev = (u32_t)(tmpdev.device & 0xff) << 24
+           | (u32_t)(tmpdev.primary & 0xff) << 16
+           | (u32_t)(tmpdev.secondary & 0xff) << 8 /* (-1 & 0xff) is 0xff */
            | 0xff;
 
        /* Look the name up on the boot device for the UNIX device number. */