aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/misc.c9
-rw-r--r--lib/misc.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/misc.c b/lib/misc.c
index 49c4aa5d..2506e291 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -681,7 +681,7 @@ int md5_verify_password( char *password, char *hash )
/* Split commands (root-style, *not* IRC-style). Handles "quoting of"
white\ space in 'various ways'. Returns a NULL-terminated static
char** so watch out with nested use! Definitely not thread-safe. */
-char **split_command_parts( char *command )
+char **split_command_parts( char *command, int limit )
{
static char *cmd[IRC_MAX_ARGS+1];
char *s, q = 0;
@@ -691,11 +691,12 @@ char **split_command_parts( char *command )
cmd[0] = command;
k = 1;
for( s = command; *s && k < IRC_MAX_ARGS; s ++ )
+ {
if( *s == ' ' && !q )
{
*s = 0;
while( *++s == ' ' );
- if( *s == '"' || *s == '\'' )
+ if( k != limit && (*s == '"' || *s == '\'') )
{
q = *s;
s ++;
@@ -703,6 +704,9 @@ char **split_command_parts( char *command )
if( *s )
{
cmd[k++] = s;
+ if (limit && k > limit) {
+ break;
+ }
s --;
}
else
@@ -721,6 +725,7 @@ char **split_command_parts( char *command )
{
q = *s = 0;
}
+ }
/* Full zero-padding for easier argc checking. */
while( k <= IRC_MAX_ARGS )
diff --git a/lib/misc.h b/lib/misc.h
index 059c8231..674a61b6 100644
--- a/lib/misc.h
+++ b/lib/misc.h
@@ -66,7 +66,7 @@ G_MODULE_EXPORT void srv_free( struct ns_srv_reply **srv );
G_MODULE_EXPORT char *word_wrap( const char *msg, int line_len );
G_MODULE_EXPORT gboolean ssl_sockerr_again( void *ssl );
G_MODULE_EXPORT int md5_verify_password( char *password, char *hash );
-G_MODULE_EXPORT char **split_command_parts( char *command );
+G_MODULE_EXPORT char **split_command_parts( char *command, int limit );
G_MODULE_EXPORT char *get_rfc822_header( const char *text, const char *header, int len );
#endif