diff options
author | tedu <tedu@openbsd.org> | 2011-06-06 14:59:16 +0000 |
---|---|---|
committer | tedu <tedu@openbsd.org> | 2011-06-06 14:59:16 +0000 |
commit | 4d0c1539306d06b9de41504918141f65ecaf88f9 (patch) | |
tree | 2f594112c90e22621d0add34c88f19317be8f964 /usr.sbin/memconfig | |
parent | Add AUTHORS section (diff) | |
download | wireguard-openbsd-4d0c1539306d06b9de41504918141f65ecaf88f9.tar.xz wireguard-openbsd-4d0c1539306d06b9de41504918141f65ecaf88f9.zip |
don't open /dev/mem to print the help, allowing mortals to read it
ok deraadt matthew
Diffstat (limited to 'usr.sbin/memconfig')
-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); } |