From 6400b60bdd8f10f8922643da8e8d235fb8874404 Mon Sep 17 00:00:00 2001 From: axel Date: Sun, 8 Oct 2006 23:27:59 +1000 Subject: Fix a few places where uncasted 0 was used as a null pointer in vararg functions, causing potential crashes on 64-bit platforms darcs-hash:20061008132759-ac50b-23fe4f70a5143b8b187780403d8d21fb69c3e83f.gz --- complete.c | 22 +++++++++++----------- highlight.c | 11 +++++------ history.c | 4 ++-- kill.c | 4 ++-- parser.c | 2 +- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/complete.c b/complete.c index 62b222b6..0f52d492 100644 --- a/complete.c +++ b/complete.c @@ -815,7 +815,7 @@ int complete_is_valid_option( const wchar_t *str, str[0] = opt[j]; str[1]=0; al_push( errors, - wcsdupcat2(_( L"Unknown option: " ), L"'", str, L"'", 0) ); + wcsdupcat2(_( L"Unknown option: " ), L"'", str, L"'", (void *)0) ); } opt_found = 0; @@ -833,12 +833,12 @@ int complete_is_valid_option( const wchar_t *str, if( hash_get_count( &gnu_match_hash )==0) { al_push( errors, - wcsdupcat2( _(L"Unknown option: "), L"'", opt, L"\'", 0) ); + wcsdupcat2( _(L"Unknown option: "), L"'", opt, L"\'", (void *)0) ); } else { al_push( errors, - wcsdupcat2( _(L"Multiple matches for option: "), L"'", opt, L"\'", 0) ); + wcsdupcat2( _(L"Multiple matches for option: "), L"'", opt, L"\'", (void *)0) ); } } } @@ -1214,7 +1214,7 @@ static void complete_cmd_desc( const wchar_t *cmd, array_list_t *comp ) wchar_t *new_el = wcsdupcat2( el, COMPLETE_SEP_STR, new_desc, - 0 ); + (void *)0 ); al_set( comp, i, new_el ); free( el ); @@ -1300,7 +1300,7 @@ static void complete_cmd( const wchar_t *cmd, nxt_completion = wcsdupcat2( nxt_path, (nxt_path[wcslen(nxt_path)-1]==L'/'?L"":L"/"), cmd, - 0 ); + (void *)0 ); if( ! nxt_completion ) continue; @@ -1357,7 +1357,7 @@ static void complete_cmd( const wchar_t *cmd, wcsdupcat2( nxt_path, (nxt_path[wcslen(nxt_path)-1]==L'/'?L"":L"/"), cmd, - 0 ); + (void *)0 ); if( ! nxt_completion ) { continue; @@ -1824,22 +1824,22 @@ static int complete_variable( const wchar_t *var, if( wcsncmp( var, name, varlen) == 0 ) { wchar_t *value_unescaped, *value; - - wchar_t *blarg; value_unescaped = env_get( name ); if( value_unescaped ) { + wchar_t *desc; + value = expand_escape_variable( value_unescaped ); /* Variable description is 'Variable: VALUE */ - blarg = wcsdupcat2( &name[varlen], COMPLETE_SEP_STR, COMPLETE_VAR_DESC_VAL, value, 0 ); + desc = wcsdupcat2( &name[varlen], COMPLETE_SEP_STR, COMPLETE_VAR_DESC_VAL, value, (void *)0 ); - if( blarg ) + if( desc ) { res =1; - al_push( comp, blarg ); + al_push( comp, desc ); } free( value ); } diff --git a/highlight.c b/highlight.c index e6712a90..47106555 100644 --- a/highlight.c +++ b/highlight.c @@ -559,8 +559,7 @@ void highlight_shell( wchar_t * buff, { int last_type = tok_last_type( &tok ); int prev_argc=0; - - + switch( last_type ) { case TOK_STRING: @@ -624,7 +623,7 @@ void highlight_shell( wchar_t * buff, int is_subcommand = 0; int mark = tok_get_pos( &tok ); color[ tok_get_pos( &tok ) ] = HIGHLIGHT_COMMAND; - + if( parser_is_subcommand( cmd ) ) { tok_next( &tok ); @@ -687,7 +686,7 @@ void highlight_shell( wchar_t * buff, else { if( error ) - al_push( error, wcsdupcat2 ( L"Unknown command \'", cmd, L"\'", 0 )); + al_push( error, wcsdupcat2 ( L"Unknown command \'", cmd, L"\'", (void *)0 )); color[ tok_get_pos( &tok ) ] = (HIGHLIGHT_ERROR); } had_cmd = 1; @@ -761,7 +760,7 @@ void highlight_shell( wchar_t * buff, { color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR; if( error ) - al_push( error, wcsdupcat2( L"Directory \'", dir, L"\' does not exist", 0 ) ); + al_push( error, wcsdupcat2( L"Directory \'", dir, L"\' does not exist", (void *)0 ) ); } } @@ -777,7 +776,7 @@ void highlight_shell( wchar_t * buff, { color[ tok_get_pos( &tok ) ] = HIGHLIGHT_ERROR; if( error ) - al_push( error, wcsdupcat2( L"File \'", target, L"\' does not exist", 0 ) ); + al_push( error, wcsdupcat2( L"File \'", target, L"\' does not exist", (void *)0 ) ); } } } diff --git a/history.c b/history.c index 4a12ae00..3b000660 100644 --- a/history.c +++ b/history.c @@ -150,7 +150,7 @@ static int history_load() &hash_wcs_cmp, 4096 ); - fn = wcsdupcat2( env_get(L"HOME"), L"/.", mode_name, L"_history", 0 ); + fn = wcsdupcat2( env_get(L"HOME"), L"/.", mode_name, L"_history", (void *)0 ); in_stream = wfopen( fn, "r" ); @@ -384,7 +384,7 @@ static void history_save() /* Save the global history */ { - fn = wcsdupcat2( env_get(L"HOME"), L"/.", mode_name, L"_history", 0 ); + fn = wcsdupcat2( env_get(L"HOME"), L"/.", mode_name, L"_history", (void *)0 ); out_stream = wfopen( fn, "w" ); if( out_stream ) diff --git a/kill.c b/kill.c index c49084a0..2fc688a7 100644 --- a/kill.c +++ b/kill.c @@ -96,7 +96,7 @@ void kill_add( wchar_t *str ) if( (disp = env_get( L"DISPLAY" )) ) { wchar_t *escaped_str = escape( str, 1 ); - wchar_t *cmd = wcsdupcat2(L"echo ", escaped_str, L"|xsel -b",0); + wchar_t *cmd = wcsdupcat2(L"echo ", escaped_str, L"|xsel -b",(void *)0); exec_subshell( cmd, 0 ); free( cut_buffer ); free( cmd ); @@ -145,7 +145,7 @@ static void kill_check_x_buffer() else { wchar_t *old = new_cut_buffer; - new_cut_buffer= wcsdupcat2( new_cut_buffer, L"\\n", next_line, 0 ); + new_cut_buffer= wcsdupcat2( new_cut_buffer, L"\\n", next_line, (void *)0 ); free( old ); free( next_line ); } diff --git a/parser.c b/parser.c index 7f4ba0cb..af34e35b 100644 --- a/parser.c +++ b/parser.c @@ -712,7 +712,7 @@ wchar_t *parser_cdpath_get( void *context, wchar_t *dir ) whole_path = wcsdupcat2( expanded_path, ( expanded_path[path_len-1] != L'/' )?L"/":L"", - dir, 0 ); + dir, (void *)0 ); free(expanded_path ); -- cgit v1.2.3