diff options
author | andreast <andreast@FreeBSD.org> | 2010-11-20 19:23:16 +0000 |
---|---|---|
committer | andreast <andreast@FreeBSD.org> | 2010-11-20 19:23:16 +0000 |
commit | 70881bc10bbea544ba7d7d89723de0868bd07916 (patch) | |
tree | 77429ad65e368ec26edb9e46ec43c0a7c2900250 /sys/boot | |
parent | f26669fe8c87c89c0c034cdab761ab409061c9ae (diff) | |
download | FreeBSD-src-70881bc10bbea544ba7d7d89723de0868bd07916.zip FreeBSD-src-70881bc10bbea544ba7d7d89723de0868bd07916.tar.gz |
Check the OF_getprop() return value before proceeding. Allocate only as
much space as needed for the mode buffer. Use strcmp, relying on OF giving
back NULL terminated strings.
Submitted by: marius
Approved by: nwhitehorn (mentor)
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/ofw/libofw/openfirm.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/boot/ofw/libofw/openfirm.c b/sys/boot/ofw/libofw/openfirm.c index 0114fb5..d4eb9d6 100644 --- a/sys/boot/ofw/libofw/openfirm.c +++ b/sys/boot/ofw/libofw/openfirm.c @@ -77,7 +77,7 @@ void OF_init(int (*openfirm)(void *)) { phandle_t options; - char mode[8]; + char mode[sizeof("true")]; openfirmware = openfirm; @@ -93,13 +93,13 @@ OF_init(int (*openfirm)(void *)) if (OF_getprop(chosen, "mmu", &mmu, sizeof(mmu)) == -1) OF_exit(); - /* + /* * Check if we run in real mode. If so, we do not need to map * memory later on. */ options = OF_finddevice("/options"); - OF_getprop(options, "real-mode?", mode, sizeof(mode)); - if (strncmp(mode, "true", 4) == 0) + if (OF_getprop(options, "real-mode?", mode, sizeof(mode)) > 0 && + strcmp(mode, "true") == 0) real_mode = 1; } |