Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
115 magnus 1
Author: Magnus Holmgren
2
Description: Avoid crashing when tab-completing an empty command line in lsftp
3
 The problem was that lsftp_s_skip returns NULL if nothing but
4
 separator characters are found, and that case wasn't handled.
5
 
6
--- a/src/sftp/rl.c
7
+++ b/src/sftp/rl.c
8
@@ -205,7 +205,7 @@ int char_quoted( char* text, int index )
9
 char** lsftp_rl_completion(char* text, int start, int end)
10
 {
11
   char** matches=NULL;
12
-  int s;
13
+  const char *s;
14
 
15
   /* If this word is at the start of the line, then it is a command to
16
    * complete.
17
@@ -213,9 +213,9 @@ char** lsftp_rl_completion(char* text, i
18
 
19
   rl_completion_append_character = ' '; /* Trailing space after word */
20
 
21
-  s = lsftp_s_skip( rl_line_buffer, " \n\t\r" ) - rl_line_buffer;
22
+  s = lsftp_s_skip( rl_line_buffer, " \n\t\r" );
23
 
24
-  if ( start == s ) /* The first word should be a command, even with spaces in front */
25
+  if ( !s || rl_line_buffer + start == s ) /* The first word should be a command, even with spaces in front */
26
     {
27
       matches = RL_COMPLETION_MATCHES(
28
                                      text,
29
@@ -231,7 +231,7 @@ char** lsftp_rl_completion(char* text, i
30
 
31
       /* Get the first word from the line (the command) */
32
 
33
-      lsftp_s_strtok( rl_line_buffer+s," \n\t\r", &tmp );
34
+      lsftp_s_strtok( s," \n\t\r", &tmp );
35
 
36
       while( (cmdname = commands[i].name) )
37
        {