mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-07 16:17:23 +02:00
cpugovctl: correctly evaluate available command line parameters
When calling `cpugovctl set` then an access to the terminating NULL pointer of argv is made.
This commit is contained in:
parent
39d7b95a26
commit
2896506340
@ -64,14 +64,9 @@ static void set_gov_state(const char *value)
|
|||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
if (argc == 2 && strncmp(argv[1], "get", 3) == 0) {
|
||||||
fprintf(stderr, "usage: cpugovctl [get] [set VALUE]\n");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strncmp(argv[1], "get", 3) == 0) {
|
|
||||||
printf("%s", get_gov_state());
|
printf("%s", get_gov_state());
|
||||||
} else if (strncmp(argv[1], "set", 3) == 0) {
|
} else if (argc == 3 && strncmp(argv[1], "set", 3) == 0) {
|
||||||
const char *value = argv[2];
|
const char *value = argv[2];
|
||||||
|
|
||||||
/* Must be root to set the state */
|
/* Must be root to set the state */
|
||||||
@ -82,6 +77,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
set_gov_state(value);
|
set_gov_state(value);
|
||||||
} else {
|
} else {
|
||||||
|
fprintf(stderr, "usage: cpugovctl [get] [set VALUE]\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user