irctk

libircclient binding for scripts
git clone https://a3nm.net/git/irctk/
Log | Files | Refs | README

commit 02a02ebca3b3dcf83d379816eca54003873dc2d3
parent 8b7d9df46eca6db192b30b7155fccb5883835fe4
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sat, 16 Jun 2012 16:58:26 +0200

more robust parsing

Diffstat:
irctk.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/irctk.c b/irctk.c @@ -32,6 +32,7 @@ #define E_CONNECT 2 #define E_THREAD 3 #define E_BADNAME 4 +#define E_BADLINE 5 enum default_destinations {DEFAULT_FIRST, DEFAULT_LAST_IN, DEFAULT_LAST_OUT, DEFAULT_ALL}; @@ -1055,9 +1056,13 @@ int start (int max_wait) char *msg; char *target = line+1; - /* TODO that's not robust AT ALL */ - while (line[i++] != ']'); - msg = line + i + 1; + while (line[i] != ']' && line[i]) + i++; + if (!line[i]) + die(E_BADLINE, "Malformed address prefix."); + msg = line + i; + if (msg[0] == ' ') + msg++; line[i-1] = 0; cmd_msg(s, target, msg); strncpy(args.last_chans_out, target, MAX_LEN-1);