[BACK]Return to env.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / sudo

Diff for /src/usr.bin/sudo/Attic/env.c between version 1.19 and 1.20

version 1.19, 2009/04/11 11:48:06 version 1.20, 2009/06/21 14:48:42
Line 1 
Line 1 
 /*  /*
  * Copyright (c) 2000-2005, 2007-2008   * Copyright (c) 2000-2005, 2007-2009
  *      Todd C. Miller <Todd.Miller@courtesan.com>   *      Todd C. Miller <Todd.Miller@courtesan.com>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
Line 49 
Line 49 
 #include "sudo.h"  #include "sudo.h"
   
 #ifndef lint  #ifndef lint
 __unused static const char rcsid[] = "$Sudo: env.c,v 1.101 2009/03/11 23:01:10 millert Exp $";  __unused static const char rcsid[] = "$Sudo: env.c,v 1.105 2009/06/15 13:10:01 millert Exp $";
 #endif /* lint */  #endif /* lint */
   
 /*  /*
Line 249 
Line 249 
     const char *val;      const char *val;
     int overwrite;      int overwrite;
 {  {
     char *estring;      char *estring, *ep;
       const char *cp;
     size_t esize;      size_t esize;
   
     if (strchr(var, '=') != NULL) {      if (!var || *var == '\0')
         errno = EINVAL;          return(EINVAL);
         return(-1);  
       /*
        * POSIX says a var name with '=' is an error but BSD
        * just ignores the '=' and anything after it.
        */
       for (cp = var; *cp && *cp != '='; cp++)
           ;
       esize = (size_t)(cp - var) + 2;
       if (val) {
           esize += strlen(val);   /* glibc treats a NULL val as "" */
     }      }
   
     esize = strlen(var) + 1 + strlen(val) + 1;      /* Allocate and fill in estring. */
     estring = emalloc(esize);      estring = ep = emalloc(esize);
       for (cp = var; *cp && *cp != '='; cp++)
     /* Build environment string and insert it. */          *ep++ = *cp;
     if (strlcpy(estring, var, esize) >= esize ||      *ep++ = '=';
         strlcat(estring, "=", esize) >= esize ||      if (val) {
         strlcat(estring, val, esize) >= esize) {          for (cp = val; *cp; cp++)
               *ep++ = *cp;
         errorx(1, "internal error, setenv() overflow");  
     }      }
       *ep = '\0';
   
     /* Sync env.envp with environ as needed. */      /* Sync env.envp with environ as needed. */
     if (env.envp != environ) {      if (env.envp != environ) {
         char **ep;          char **ep;

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20