diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2011-06-06 14:59:17 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2011-06-06 14:59:17 +0000 |
commit | e33a8f138329dd436845db5cdc75f61d21b66984 (patch) | |
tree | 2fdfb9f478bd58501533b04a571fbbe4afb4e206 /usr.sbin | |
parent | e802374cdcb419f5ede88a18f54d77029677e1c6 (diff) |
don't open /dev/mem to print the help, allowing mortals to read it
ok deraadt matthew
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/memconfig/memconfig.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.sbin/memconfig/memconfig.c b/usr.sbin/memconfig/memconfig.c index f684b6d9e7f..978ac038862 100644 --- a/usr.sbin/memconfig/memconfig.c +++ b/usr.sbin/memconfig/memconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: memconfig.c,v 1.13 2010/04/20 16:10:27 marco Exp $ */ +/* $OpenBSD: memconfig.c,v 1.14 2011/06/06 14:59:16 tedu Exp $ */ /*- * Copyright (c) 1999 Michael Smith <msmith@freebsd.org> @@ -106,17 +106,18 @@ struct int main(int argc, char *argv[]) { - int i, memfd; + int i, memfd = -1; if (argc < 2) { help(NULL); } else { - if ((memfd = open("/dev/mem", O_RDONLY)) == -1) - err(1, "can't open /dev/mem"); - for (i = 0; functions[i].cmd != NULL; i++) if (!strcmp(argv[1], functions[i].cmd)) break; + + if ((functions[i].func != helpfunc) && + (memfd = open("/dev/mem", O_RDONLY)) == -1) + err(1, "can't open /dev/mem"); functions[i].func(memfd, argc - 1, argv + 1); close(memfd); } |