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

Diff for /src/usr.bin/sudo/Attic/sudo_setenv.c between version 1.1 and 1.2

version 1.1, 1999/11/18 16:29:01 version 1.2, 2000/11/21 17:58:44
Line 59 
Line 59 
 #endif /* !STDC_HEADERS */  #endif /* !STDC_HEADERS */
   
 #ifndef lint  #ifndef lint
 static const char rcsid[] = "$Sudo: sudo_setenv.c,v 1.40 1999/07/31 16:19:48 millert Exp $";  static const char rcsid[] = "$Sudo: sudo_setenv.c,v 1.41 2000/09/14 20:48:58 millert Exp $";
 #endif /* lint */  #endif /* lint */
   
   
 /*  /*
  * Add a string of the form "var=val" to the environment.  If we are unable   * Add a string of the form "var=val" to the environment.  Exits if it is
  * to expand the current environent, return -1, else return 0.   * unable to expand the current environent.
  */   */
 int  void
 sudo_setenv(var, val)  sudo_setenv(var, val)
     char *var;      char *var;
     char *val;      char *val;
 {  {
   
 #ifdef HAVE_SETENV  #ifdef HAVE_SETENV
     return(setenv(var, val, 1));      if (setenv(var, val, 1) == -1) {
           (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
           exit(1);
       }
 #else  #else
     char *envstring, *tmp;      char *envstring, *tmp;
   
     envstring = tmp = (char *) malloc(strlen(var) + strlen(val) + 2);      envstring = tmp = (char *) malloc(strlen(var) + strlen(val) + 2);
     if (envstring == NULL)      if (envstring == NULL) {
         return(-1);          (void) fprintf(stderr, "%s: cannot allocate memory!\n", Argv[0]);
           exit(1);
       }
   
     while ((*tmp++ = *var++))      while ((*tmp++ = *var++))
         ;          ;
Line 90 
Line 95 
     while ((*tmp++ = *val++))      while ((*tmp++ = *val++))
         ;          ;
   
     return(putenv(envstring));      putenv(envstring);
 #endif /* HAVE_SETENV */  #endif /* HAVE_SETENV */
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2