From 5c9b42e260fb8797cad138d3ead0810fc72f01b2 Mon Sep 17 00:00:00 2001 From: Christopher Nilsson Date: Sun, 12 Sep 2010 13:16:11 +1000 Subject: 'functions --copy': added sanity check on new function name. Now matches function create behaviour, running the new function name through wcsfuncname() and parser_keywords_is_reserved(), before allowing the copy. --- builtin.c | 10 ++++++++++ function.c | 2 -- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/builtin.c b/builtin.c index ff849f05..0d113962 100644 --- a/builtin.c +++ b/builtin.c @@ -1471,6 +1471,16 @@ static int builtin_functions( wchar_t **argv ) return STATUS_BUILTIN_ERROR; } + if( (wcsfuncname( new_func ) != 0) || parser_keywords_is_reserved( new_func ) ) + { + sb_printf( sb_err, + _( L"%ls: Illegal function name '%ls'\n"), + argv[0], + new_func ); + builtin_print_help( argv[0], sb_err ); + return STATUS_BUILTIN_ERROR; + } + // keep things simple: don't allow existing names to be copy targets. if( function_exists( new_func ) ) { diff --git a/function.c b/function.c index 5b2dcd5a..2ca736dc 100644 --- a/function.c +++ b/function.c @@ -226,8 +226,6 @@ int function_copy( const wchar_t *name, const wchar_t *new_name ) CHECK( name, 0 ); CHECK( new_name, 0 ); - fn_events = 0; - orig_d = (function_internal_data_t *)hash_get(&function, name); if( !orig_d ) return 0; -- cgit v1.2.3