dumpkmap,loadkmap: abort if there are params on cmdline
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Jun 2010 16:09:57 +0000 (18:09 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 6 Jun 2010 16:09:57 +0000 (18:09 +0200)
function                                             old     new   delta
loadkmap_main                                        201     219     +18
dumpkmap_main                                        208     223     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
console-tools/dumpkmap.c
console-tools/loadkmap.c

index 061fc4792c1fec9e06b39ed898c304d3ac43d7f0..a03b593400870b8d68b7e2dd29ad7f5de98fd0d8 100644 (file)
@@ -24,12 +24,17 @@ struct kbentry {
 #define MAX_NR_KEYMAPS 256
 
 int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
+int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
 {
        struct kbentry ke;
        int i, j, fd;
        RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS);
 
+       /* When user accidentally runs "dumpkmap FILE"
+        * instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
+        * Let's prevent it: */
+       if (argv[1])
+               bb_show_usage();
 /*     bb_warn_ignoring_args(argv[1]);*/
 
        fd = get_console_fd_or_die();
index 912291a7dd11511f00c079ba688b646df79e310e..9e2c779e0f0eefb027517b1bc4a1b8f2c0eed8b3 100644 (file)
@@ -32,6 +32,11 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
 /*     const char *tty_name = CURRENT_TTY; */
        RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS);
 
+       /* When user accidentally runs "loadkmap FILE"
+        * instead of "loadkmap <FILE", we end up waiting for input from tty.
+        * Let's prevent it: */
+       if (argv[1])
+               bb_show_usage();
 /* bb_warn_ignoring_args(argv[1]); */
        fd = get_console_fd_or_die();
 /* or maybe: