From bdd4f624c712d3cd67ca500e19e2ed1a1f628f0d Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Fri, 21 Jun 2019 16:04:15 +1000 Subject: [PATCH] Handle 301 numeric with missing message away message argument Reported-by: trn --- Changelog | 2 ++ source/numbers.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Changelog b/Changelog index ffc3fa9..ed6b16c 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2.2] +* Handle 301 numeric with missing message argument. Reported by trn. (caf) + * Display "Servers exhausted. Restarting." message at the right time. (caf) * Fix bug where the initial server connection was only retried one less than diff --git a/source/numbers.c b/source/numbers.c index 22a9980..0303943 100644 --- a/source/numbers.c +++ b/source/numbers.c @@ -724,18 +724,25 @@ void numbered_command(char *from, int comm, char **ArgList) } case 301: /* #define RPL_AWAY 301 */ { - PasteArgs(ArgList, 1); + const char *away_msg = ""; + + if (ArgList[1]) + { + PasteArgs(ArgList, 1); + away_msg = ArgList[1]; + } + if (get_int_var(SHOW_AWAY_ONCE_VAR)) { - if (!last_away_msg || strcmp(last_away_nick, from) || strcmp(last_away_msg, ArgList[1])) + if (!last_away_msg || strcmp(last_away_nick, from) || strcmp(last_away_msg, away_msg)) { malloc_strcpy(&last_away_nick, from); - malloc_strcpy(&last_away_msg, ArgList[1]); + malloc_strcpy(&last_away_msg, away_msg); } else break; } - if (do_hook(current_numeric, "%s %s", ArgList[0], ArgList[1])) - put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOIS_AWAY_FSET),"%s %s", ArgList[0], ArgList[1])); + if (do_hook(current_numeric, "%s %s", ArgList[0], away_msg)) + put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOIS_AWAY_FSET),"%s %s", ArgList[0], away_msg)); break; } case 302: /* #define RPL_USERHOST 302 */