diff options
author | 2006-06-09 09:52:12 +1000 | |
---|---|---|
committer | 2006-06-09 09:52:12 +1000 | |
commit | f7118e769f53678853eb17556097b82f100e9746 (patch) | |
tree | 775f5fc8046dc775a05db8fd293a58de5668943e /env.c | |
parent | 93ae00e8e50b9c1319ff478cbecbf482bf6d217e (diff) |
Add more function input validation checks
darcs-hash:20060608235212-ac50b-25fd55f96356af65d4da1eec100cc954b4a9f81e.gz
Diffstat (limited to 'env.c')
-rw-r--r-- | env.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -623,6 +623,12 @@ int env_set( const wchar_t *key, event_t ev; int is_universal = 0; + if( !key ) + { + debug( 0, L"%s called with null input", __func__ ); + return ENV_INVALID; + } + if( (var_mode & ENV_USER ) && hash_get( &env_read_only, key ) ) { @@ -867,6 +873,12 @@ int env_remove( const wchar_t *key, int var_mode ) env_node_t *first_node; int erased = 0; + if( !key ) + { + debug( 0, L"%s called with null input", __func__ ); + return 1; + } + if( (var_mode & ENV_USER ) && hash_get( &env_read_only, key ) ) { @@ -925,6 +937,12 @@ wchar_t *env_get( const wchar_t *key ) env_node_t *env = top; wchar_t *item; + if( !key ) + { + debug( 0, L"%s called with null input", __func__ ); + return 0; + } + if( wcscmp( key, L"history" ) == 0 ) { wchar_t *current; @@ -1023,9 +1041,15 @@ int env_exist( const wchar_t *key, int mode ) env_node_t *env; wchar_t *item=0; + if( !key ) + { + debug( 0, L"%s called with null input", __func__ ); + return 0; + } + /* Read only variables all exist, and they are all global. A local - varion can not exist. + version can not exist. */ if( ! (mode & ENV_LOCAL) && ! (mode & ENV_UNIVERSAL) ) { |