Fix setenv and unsetenv corner cases.
* environ.cc (setenv): Detect invalid argument. (unsetenv): Distinguish EFAULT from EINVAL.
This commit is contained in:
		@@ -1,3 +1,8 @@
 | 
			
		||||
2009-11-16  Eric Blake  <ebb9@byu.net>
 | 
			
		||||
 | 
			
		||||
	* environ.cc (setenv): Detect invalid argument.
 | 
			
		||||
	(unsetenv): Distinguish EFAULT from EINVAL.
 | 
			
		||||
 | 
			
		||||
2009-11-13  Corinna Vinschen  <corinna@vinschen.de>
 | 
			
		||||
 | 
			
		||||
	* net.cc (fdsock): Fill _rmem and _wmem with valid values returned
 | 
			
		||||
 
 | 
			
		||||
@@ -413,10 +413,11 @@ setenv (const char *name, const char *value, int overwrite)
 | 
			
		||||
  myfault efault;
 | 
			
		||||
  if (efault.faulted (EFAULT))
 | 
			
		||||
    return -1;
 | 
			
		||||
  if (!*name)
 | 
			
		||||
    return 0;
 | 
			
		||||
  if (*value == '=')
 | 
			
		||||
    value++;
 | 
			
		||||
  if (!name || !*name || strchr (name, '='))
 | 
			
		||||
    {
 | 
			
		||||
      set_errno (EINVAL);
 | 
			
		||||
      return -1;
 | 
			
		||||
    }
 | 
			
		||||
  return _addenv (name, value, !!overwrite);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -427,7 +428,9 @@ unsetenv (const char *name)
 | 
			
		||||
  register char **e;
 | 
			
		||||
  int offset;
 | 
			
		||||
  myfault efault;
 | 
			
		||||
  if (efault.faulted () || *name == '\0' || strchr (name, '='))
 | 
			
		||||
  if (efault.faulted (EFAULT))
 | 
			
		||||
    return -1;
 | 
			
		||||
  if (!name || *name == '\0' || strchr (name, '='))
 | 
			
		||||
    {
 | 
			
		||||
      set_errno (EINVAL);
 | 
			
		||||
      return -1;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user