aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-03-29 10:48:42 +0200
committerMichael Vetter <jubalh@iodoru.org>2021-03-29 10:48:42 +0200
commit3c1e4bac3ae640bc4c451d7d4a1c06146e13a15a (patch)
tree8817200d0bd211be198dbf4e51ae6ae2ae4f64fc /src/command
parenta09d49d884578fdaea01f9ff4be0fcc9f0fe7746 (diff)
downloadprofani-tty-3c1e4bac3ae640bc4c451d7d4a1c06146e13a15a.tar.gz
Fix segfault in cmd_autoaway()
Two mistakes were here: * `/autoaway time away` without a time argument segfaulted * `/autoaway message away` without a mesage set to (null). We have `/autoaway message off to set it off. Also use g_strcmp0() instead of strcmp().
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_funcs.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 07a444f7..115db27f 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6488,13 +6488,13 @@ cmd_ping(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_autoaway(ProfWin* window, const char* const command, gchar** args)
{
- if ((strcmp(args[0], "mode") != 0) && (strcmp(args[0], "time") != 0) && (strcmp(args[0], "message") != 0) && (strcmp(args[0], "check") != 0)) {
+ if ((g_strcmp0(args[0], "mode") != 0) && (g_strcmp0(args[0], "time") != 0) && (g_strcmp0(args[0], "message") != 0) && (g_strcmp0(args[0], "check") != 0)) {
cons_show("Setting must be one of 'mode', 'time', 'message' or 'check'");
return TRUE;
}
- if (strcmp(args[0], "mode") == 0) {
- if ((strcmp(args[1], "idle") != 0) && (strcmp(args[1], "away") != 0) && (strcmp(args[1], "off") != 0)) {
+ if (g_strcmp0(args[0], "mode") == 0) {
+ if ((g_strcmp0(args[1], "idle") != 0) && (g_strcmp0(args[1], "away") != 0) && (g_strcmp0(args[1], "off") != 0)) {
cons_show("Mode must be one of 'idle', 'away' or 'off'");
} else {
prefs_set_string(PREF_AUTOAWAY_MODE, args[1]);
@@ -6504,7 +6504,7 @@ cmd_autoaway(ProfWin* window, const char* const command, gchar** args)
return TRUE;
}
- if (strcmp(args[0], "time") == 0) {
+ if ((g_strcmp0(args[0], "time") == 0) && (args[2] != NULL)) {
if (g_strcmp0(args[1], "away") == 0) {
int minutesval = 0;
char* err_msg = NULL;
@@ -6550,11 +6550,14 @@ cmd_autoaway(ProfWin* window, const char* const command, gchar** args)
cons_bad_cmd_usage(command);
return TRUE;
}
+ } else {
+ cons_bad_cmd_usage(command);
+ return TRUE;
}
- if (strcmp(args[0], "message") == 0) {
- if (g_strcmp0(args[1], "away") == 0) {
- if (strcmp(args[2], "off") == 0) {
+ if (g_strcmp0(args[0], "message") == 0) {
+ if (g_strcmp0(args[1], "away") == 0 && args[2] != NULL) {
+ if (g_strcmp0(args[2], "off") == 0) {
prefs_set_string(PREF_AUTOAWAY_MESSAGE, NULL);
cons_show("Auto away message cleared.");
} else {
@@ -6564,7 +6567,7 @@ cmd_autoaway(ProfWin* window, const char* const command, gchar** args)
return TRUE;
} else if (g_strcmp0(args[1], "xa") == 0) {
- if (strcmp(args[2], "off") == 0) {
+ if (g_strcmp0(args[2], "off") == 0) {
prefs_set_string(PREF_AUTOXA_MESSAGE, NULL);
cons_show("Auto xa message cleared.");
} else {
@@ -6579,7 +6582,7 @@ cmd_autoaway(ProfWin* window, const char* const command, gchar** args)
}
}
- if (strcmp(args[0], "check") == 0) {
+ if (g_strcmp0(args[0], "check") == 0) {
_cmd_set_boolean_preference(args[1], command, "Online check", PREF_AUTOAWAY_CHECK);
return TRUE;
}