summaryrefslogtreecommitdiff
path: root/src/irc/core/irc.c
diff options
context:
space:
mode:
authorWill Storey <will@summercat.com>2017-10-21 20:00:25 -0700
committerWill Storey <will@summercat.com>2017-10-24 19:51:01 -0700
commit8843d4f77d8e829135e2ff9b354990134c58c46a (patch)
tree49d253aea45c10fb3cea79971030f8279f9c22b1 /src/irc/core/irc.c
parentcfa51c5ae2c06f4b93f443c986ec0bc316c860a4 (diff)
downloadirssi-8843d4f77d8e829135e2ff9b354990134c58c46a.zip
Strip : from <trailing> parameters
This is to fix #601. The function used to extract the mode string assumed that ":" would only occur in a particular spot. This lead to the possibility that ":" could be treated as part of things like nicknames or mode arguments, where it should have been stripped as part of protocol escaping.
Diffstat (limited to 'src/irc/core/irc.c')
-rw-r--r--src/irc/core/irc.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/irc/core/irc.c b/src/irc/core/irc.c
index 4dce3fcf..790c7122 100644
--- a/src/irc/core/irc.c
+++ b/src/irc/core/irc.c
@@ -40,6 +40,8 @@ static int signal_server_incoming;
# define MAX_SOCKET_READS 5
#endif
+static void strip_params_colon(char *const);
+
/* The core of the irc_send_cmd* functions. If `raw' is TRUE, the `cmd'
won't be checked at all if it's 512 bytes or not, or if it contains
line feeds or not. Use with extreme caution! */
@@ -269,8 +271,9 @@ char *event_get_params(const char *data, int count, ...)
while (count-- > 0) {
str = (char **) va_arg(args, char **);
if (count == 0 && rest) {
- /* put the rest to last parameter */
- tmp = *datad == ':' ? datad+1 : datad;
+ /* Put the rest into the last parameter. */
+ strip_params_colon(datad);
+ tmp = datad;
} else {
tmp = event_get_param(&datad);
}
@@ -281,6 +284,31 @@ char *event_get_params(const char *data, int count, ...)
return duprec;
}
+/* Given a string containing <params>, strip any colon prefixing <trailing>. */
+static void strip_params_colon(char *const params)
+{
+ if (!params) {
+ return;
+ }
+
+ char *s = params;
+ while (*s != '\0') {
+ if (*s == ':') {
+ memmove(s, s+1, strlen(s+1)+1);
+ return;
+ }
+
+ s = strchr(s, ' ');
+ if (!s) {
+ return;
+ }
+
+ while (*s == ' ') {
+ s++;
+ }
+ }
+}
+
static void irc_server_event(IRC_SERVER_REC *server, const char *line,
const char *nick, const char *address)
{