Add more function input validation checks

darcs-hash:20060608235212-ac50b-25fd55f96356af65d4da1eec100cc954b4a9f81e.gz
This commit is contained in:
axel
2006-06-09 09:52:12 +10:00
parent 93ae00e8e5
commit f7118e769f
8 changed files with 162 additions and 16 deletions

26
env.c
View File

@@ -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) )
{