aboutsummaryrefslogtreecommitdiffhomepage
path: root/function.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-06-08 10:01:45 +1000
committerGravatar axel <axel@liljencrantz.se>2006-06-08 10:01:45 +1000
commit93ae00e8e50b9c1319ff478cbecbf482bf6d217e (patch)
treefaef9470f4fa7c575b96a746984ad3daaf1ddf03 /function.c
parentd7eb084b9d0c48ea23cf5774beefa12119adc2e8 (diff)
Do input validation in various functions in function.c and complete.c
darcs-hash:20060608000145-ac50b-1088c3f5e3c1ad2759c13400e5dda2d21858fedc.gz
Diffstat (limited to 'function.c')
-rw-r--r--function.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/function.c b/function.c
index be42b60d..21fe6a95 100644
--- a/function.c
+++ b/function.c
@@ -157,6 +157,13 @@ void function_add( const wchar_t *name,
wchar_t *cmd_end;
function_data_t *d;
+
+ if( !name || !val )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
function_remove( name );
d = malloc( sizeof( function_data_t ) );
@@ -185,6 +192,13 @@ void function_add( const wchar_t *name,
int function_exists( const wchar_t *cmd )
{
+
+ if( !cmd )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
if( parser_is_reserved(cmd) )
return 0;
@@ -198,6 +212,12 @@ void function_remove( const wchar_t *name )
const void *dv;
function_data_t *d;
event_t ev;
+
+ if( !name )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
hash_remove( &function,
name,
@@ -219,6 +239,13 @@ void function_remove( const wchar_t *name )
const wchar_t *function_get_definition( const wchar_t *argv )
{
function_data_t *data;
+
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -229,6 +256,12 @@ const wchar_t *function_get_definition( const wchar_t *argv )
const wchar_t *function_get_desc( const wchar_t *argv )
{
function_data_t *data;
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -240,6 +273,12 @@ const wchar_t *function_get_desc( const wchar_t *argv )
void function_set_desc( const wchar_t *name, const wchar_t *desc )
{
function_data_t *data;
+ if( !name || !desc )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
load( name );
data = (function_data_t *)hash_get( &function, name );
if( data == 0 )
@@ -294,6 +333,12 @@ static void get_names_internal_all( const void *key,
void function_get_names( array_list_t *list, int get_hidden )
{
+ if( !list )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return;
+ }
+
autoload_names( list, get_hidden );
if( get_hidden )
@@ -310,6 +355,13 @@ void function_get_names( array_list_t *list, int get_hidden )
const wchar_t *function_get_definition_file( const wchar_t *argv )
{
function_data_t *data;
+
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return 0;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )
@@ -322,6 +374,13 @@ const wchar_t *function_get_definition_file( const wchar_t *argv )
int function_get_definition_offset( const wchar_t *argv )
{
function_data_t *data;
+
+ if( !argv )
+ {
+ debug( 0, L"%s called with null input", __func__ );
+ return -1;
+ }
+
load( argv );
data = (function_data_t *)hash_get( &function, argv );
if( data == 0 )