diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-12-19 11:18:59 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-12-19 11:18:59 +0100 |
commit | 267313304e113e0f67fbc60d5c1aa233e6f96a3d (patch) | |
tree | 0fc7ea5479944918c730fef90de2b8368f404a6d /src/plugins/irc | |
parent | 33b6adc3d38ba44078728877a5851ce0e9b36450 (diff) | |
download | weechat-267313304e113e0f67fbc60d5c1aa233e6f96a3d.zip |
irc: fix calls to weechat_string_toupper
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-command.c | 21 | ||||
-rw-r--r-- | src/plugins/irc/irc-ctcp.c | 14 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 11 | ||||
-rw-r--r-- | src/plugins/irc/irc-redirect.c | 10 |
4 files changed, 36 insertions, 20 deletions
diff --git a/src/plugins/irc/irc-command.c b/src/plugins/irc/irc-command.c index f906b8311..a0072f535 100644 --- a/src/plugins/irc/irc-command.c +++ b/src/plugins/irc/irc-command.c @@ -813,7 +813,7 @@ IRC_COMMAND_CALLBACK(allserv) IRC_COMMAND_CALLBACK(auth) { - char str_msg_auth[512]; + char str_msg_auth[512], *str_msg_auth_upper; int sasl_mechanism; IRC_BUFFER_GET_SERVER(buffer); @@ -861,9 +861,14 @@ IRC_COMMAND_CALLBACK(auth) snprintf (str_msg_auth, sizeof (str_msg_auth), "AUTHENTICATE %s", irc_sasl_mechanism_string[sasl_mechanism]); - weechat_string_toupper (str_msg_auth); - irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, - str_msg_auth); + str_msg_auth_upper = weechat_string_toupper (str_msg_auth); + if (str_msg_auth_upper) + { + irc_server_sendf (ptr_server, + IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, + str_msg_auth_upper); + free (str_msg_auth_upper); + } } } else @@ -1505,12 +1510,10 @@ IRC_COMMAND_CALLBACK(cap) if (argc > 1) { - cap_cmd = strdup (argv[1]); + cap_cmd = weechat_string_toupper (argv[1]); if (!cap_cmd) WEECHAT_COMMAND_ERROR; - weechat_string_toupper (cap_cmd); - if ((strcmp (cap_cmd, "LS") == 0) && !argv_eol[2]) { irc_server_sendf (ptr_server, IRC_SERVER_SEND_OUTQ_PRIO_HIGH, NULL, @@ -1829,15 +1832,13 @@ IRC_COMMAND_CALLBACK(ctcp) if (!targets) WEECHAT_COMMAND_ERROR; - ctcp_type = strdup (argv[arg_type]); + ctcp_type = weechat_string_toupper (argv[arg_type]); if (!ctcp_type) { weechat_string_free_split (targets); WEECHAT_COMMAND_ERROR; } - weechat_string_toupper (ctcp_type); - if ((strcmp (ctcp_type, "PING") == 0) && !argv_eol[arg_args]) { /* generate argument for PING if not provided */ diff --git a/src/plugins/irc/irc-ctcp.c b/src/plugins/irc/irc-ctcp.c index 2faab81e3..dffbea5e0 100644 --- a/src/plugins/irc/irc-ctcp.c +++ b/src/plugins/irc/irc-ctcp.c @@ -270,10 +270,11 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, { struct t_hashtable *hashtable; int number; - char hash_key[32], *str_args_color, *dup_ctcp, *dup_args; + char hash_key[32], *str_args_color, *dup_ctcp, *dup_ctcp_upper, *dup_args; const char *str_args; dup_ctcp = NULL; + dup_ctcp_upper = NULL; dup_args = NULL; hashtable = NULL; @@ -284,7 +285,10 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, dup_ctcp = weechat_string_replace (ctcp, "\01", " "); if (!dup_ctcp) goto end; - weechat_string_toupper (dup_ctcp); + + dup_ctcp_upper = weechat_string_toupper (dup_ctcp); + if (!dup_ctcp_upper) + goto end; if (arguments) { @@ -303,7 +307,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, NULL, "NOTICE %s :\01%s%s%s\01", nick, - dup_ctcp, + dup_ctcp_upper, (dup_args) ? " " : "", (dup_args) ? dup_args : ""); if (!hashtable) @@ -338,7 +342,7 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, nick, IRC_COLOR_RESET, IRC_COLOR_CHAT_CHANNEL, - dup_ctcp, + dup_ctcp_upper, (str_args_color[0]) ? IRC_COLOR_RESET : "", (str_args_color[0]) ? " " : "", str_args_color); @@ -350,6 +354,8 @@ irc_ctcp_reply_to_nick (struct t_irc_server *server, end: if (dup_ctcp) free (dup_ctcp); + if (dup_ctcp_upper) + free (dup_ctcp_upper); if (dup_args) free (dup_args); if (hashtable) diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index fabf7e351..8bdea9c21 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -842,7 +842,8 @@ IRC_PROTOCOL_CALLBACK(cap) { char **caps_supported, **caps_added, **caps_removed; char **caps_enabled, *pos_value, *str_name, **str_caps; - char str_msg_auth[512], **str_caps_enabled, **str_caps_disabled, *str_params; + char str_msg_auth[512], *str_msg_auth_upper, **str_caps_enabled; + char **str_caps_disabled, *str_params; int arg_caps, num_caps_supported, num_caps_added, num_caps_removed; int num_caps_enabled, sasl_to_do, sasl_mechanism; int i, j, timeout, last_reply; @@ -1094,8 +1095,12 @@ IRC_PROTOCOL_CALLBACK(cap) snprintf (str_msg_auth, sizeof (str_msg_auth), "AUTHENTICATE %s", irc_sasl_mechanism_string[sasl_mechanism]); - weechat_string_toupper (str_msg_auth); - irc_server_sendf (server, 0, NULL, str_msg_auth); + str_msg_auth_upper = weechat_string_toupper (str_msg_auth); + if (str_msg_auth_upper) + { + irc_server_sendf (server, 0, NULL, str_msg_auth_upper); + free (str_msg_auth_upper); + } if (server->hook_timer_sasl) weechat_unhook (server->hook_timer_sasl); timeout = IRC_SERVER_OPTION_INTEGER( diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c index 02b991d0e..b55cb0ce1 100644 --- a/src/plugins/irc/irc-redirect.c +++ b/src/plugins/irc/irc-redirect.c @@ -406,7 +406,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server, const char *cmd_filter) { struct t_irc_redirect *new_redirect; - char **items[4], *pos, *error; + char **items[4], *item_upper, *pos, *error; int i, j, num_items[4]; long value; struct t_hashtable *hash_cmd[4]; @@ -466,8 +466,12 @@ irc_redirect_new_with_commands (struct t_irc_server *server, if (!error || error[0]) value = -1; } - weechat_string_toupper (items[i][j]); - weechat_hashtable_set (hash_cmd[i], items[i][j], &value); + item_upper = weechat_string_toupper (items[i][j]); + if (item_upper) + { + weechat_hashtable_set (hash_cmd[i], item_upper, &value); + free (item_upper); + } } else { |