diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2011-01-17 08:39:44 +0000 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2011-01-17 08:39:44 +0000 |
commit | 6804edfc85c96fbda043ef9dd5d90122165bd32a (patch) | |
tree | 3ec9bf62002052f8632d20c9ca5212d4500e7e3c /src | |
parent | bfb87f2d5138f6494d7ff5f92fca34ed6040ac84 (diff) |
Better error checking of argc for --applet call.
Diffstat (limited to 'src')
-rw-r--r-- | src/rc/rc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c index af346657..14be8683 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -821,11 +821,13 @@ main(int argc, char **argv) * than trusting argv[0], as argv[0] is not going to be the applet value if * we are doing SELinux context switching. For this, we allow calls such as * 'rc --applet APPLET', and shift ALL of argv down by two array items. */ - if(strcmp(basename_c(argv[0]), "rc") == 0 && strcmp(argv[1], "--applet") == 0) { - for(i = 2; i < argc; i++) - argv[i-2] = argv[i]; - argv[argc-2] = NULL; - argv[argc-1] = NULL; + if (strcmp(basename_c(argv[0]), "rc") == 0 && argc > 1 && strcmp(argv[1], "--applet") == 0) { + if (argc == 2) + eerrorx("applet argument required"); + for (i = 2; i < argc; i++) + argv[i - 2] = argv[i]; + argv[argc - 2] = NULL; + argv[argc - 1] = NULL; argc -= 2; } /* Now we can trust our applet value in argv[0] */ |