From: Pekka Riikonen Date: Thu, 21 Jun 2001 15:10:06 +0000 (+0000) Subject: updates X-Git-Tag: 1.2.beta1~2140 X-Git-Url: http://git.silcnet.org/gitweb/?a=commitdiff_plain;h=d5b383775b63161db8d94f21df4b3f4029ba2866;p=crypto.git updates --- diff --git a/CHANGES b/CHANGES index 85738f14..2a159c48 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Thu Jun 21 17:10:08 CEST 2001 Pekka Riikonen + + * Fixed the silc_parse_command_line to remove extra spaces + from the start and end of the arguments. Affected file is + lib/silcutil/silcutil.c. + Tue Jun 19 22:10:36 EEST 2001 Pekka Riikonen * Fixed a possible crash in silc_packet_send_prepare. It now diff --git a/TODO b/TODO index 83903d2d..ad15d634 100644 --- a/TODO +++ b/TODO @@ -3,9 +3,6 @@ TODO/bugs in Irssi SILC client o LEAVE does not work correctly, it doesn't leave the channel for real! - o The input line parser in client (librarys) doesn't like extra spaces - at the end of line (like after commands). - o /KICK does not remove the client from Irssi's NAMES list. o Giving KILL command crashes the client. diff --git a/lib/silcutil/silcutil.c b/lib/silcutil/silcutil.c index dee8d90b..56ff3090 100644 --- a/lib/silcutil/silcutil.c +++ b/lib/silcutil/silcutil.c @@ -420,15 +420,21 @@ void silc_parse_command_line(unsigned char *buffer, int i, len = 0; int argc = 0; const char *cp = buffer; + char *tmp; *parsed = silc_calloc(1, sizeof(**parsed)); *parsed_lens = silc_calloc(1, sizeof(**parsed_lens)); /* Get the command first */ len = strcspn(cp, " "); - (*parsed)[0] = silc_to_upper((char *)cp); + tmp = silc_to_upper((char *)cp); + (*parsed)[0] = silc_calloc(len + 1, sizeof(char)); + memcpy((*parsed)[0], tmp, len); + silc_free(tmp); (*parsed_lens)[0] = len; - cp += len + 1; + cp += len; + while (*cp == ' ') + cp++; argc++; /* Parse arguments */ @@ -439,6 +445,10 @@ void silc_parse_command_line(unsigned char *buffer, len = strcspn(cp, " "); else len = strlen(cp); + while (len && cp[len - 1] == ' ') + len--; + if (!len) + break; *parsed = silc_realloc(*parsed, sizeof(**parsed) * (argc + 1)); *parsed_lens = silc_realloc(*parsed_lens, @@ -452,7 +462,8 @@ void silc_parse_command_line(unsigned char *buffer, if (strlen(cp) == 0) break; else - cp++; + while (*cp == ' ') + cp++; } }