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

Diff for /src/usr.bin/sudo/Attic/parse.lex between version 1.8 and 1.9

version 1.8, 2003/01/07 00:04:48 version 1.9, 2003/03/15 21:23:54
Line 1 
Line 1 
 %{  %{
 /*  /*
  * Copyright (c) 1996, 1998-2001 Todd C. Miller <Todd.Miller@courtesan.com>   * Copyright (c) 1996, 1998-2003 Todd C. Miller <Todd.Miller@courtesan.com>
  * All rights reserved.   * All rights reserved.
  *   *
  * This code is derived from software contributed by Chris Jepeway.   * This code is derived from software contributed by Chris Jepeway.
Line 68 
Line 68 
 #include <sudo.tab.h>  #include <sudo.tab.h>
   
 #ifndef lint  #ifndef lint
 static const char rcsid[] = "$Sudo: parse.lex,v 1.119 2002/03/16 00:44:47 millert Exp $";  static const char rcsid[] = "$Sudo: parse.lex,v 1.126 2003/03/15 20:31:02 millert Exp $";
 #endif /* lint */  #endif /* lint */
   
 #undef yywrap           /* guard against a yywrap macro */  #undef yywrap           /* guard against a yywrap macro */
Line 99 
Line 99 
 OCTET                   (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5])  OCTET                   (1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5])
 DOTTEDQUAD              {OCTET}(\.{OCTET}){3}  DOTTEDQUAD              {OCTET}(\.{OCTET}){3}
 HOSTNAME                [[:alnum:]_-]+  HOSTNAME                [[:alnum:]_-]+
 WORD                    ([^#@!=:,\(\) \t\n\\]|\\[^\n])+  WORD                    ([^#>@!=:,\(\) \t\n\\]|\\[^\n])+
 ENVAR                   ([^#!=, \t\n\\]|\\[^\n])([^#=, \t\n\\]|\\[^\n])*  ENVAR                   ([^#!=, \t\n\\]|\\[^\n])([^#=, \t\n\\]|\\[^\n])*
 DEFVAR                  [a-z_]+  DEFVAR                  [a-z_]+
   
Line 175 
Line 175 
                         }                       /* a command line arg */                          }                       /* a command line arg */
 }  }
   
 <INITIAL>^Defaults[:@]? {  <INITIAL>^Defaults[:@>]? {
                             BEGIN GOTDEFS;                              BEGIN GOTDEFS;
                             switch (yytext[8]) {                              switch (yytext[8]) {
                                 case ':':                                  case ':':
                                     LEXTRACE("DEFAULTS_USER ");                                      LEXTRACE("DEFAULTS_USER ");
                                     return(DEFAULTS_USER);                                      return(DEFAULTS_USER);
                                   case '>':
                                       LEXTRACE("DEFAULTS_RUNAS ");
                                       return(DEFAULTS_RUNAS);
                                 case '@':                                  case '@':
                                     LEXTRACE("DEFAULTS_HOST ");                                      LEXTRACE("DEFAULTS_HOST ");
                                     return(DEFAULTS_HOST);                                      return(DEFAULTS_HOST);
Line 362 
Line 365 
     int i, j;      int i, j;
   
     yylval.string = (char *) malloc(len + 1);      yylval.string = (char *) malloc(len + 1);
     if (yylval.string == NULL)      if (yylval.string == NULL) {
         yyerror("unable to allocate memory");          yyerror("unable to allocate memory");
           return;
       }
   
     /* Copy the string and collapse any escaped characters. */      /* Copy the string and collapse any escaped characters. */
     for (i = 0, j = 0; i < len; i++, j++) {      for (i = 0, j = 0; i < len; i++, j++) {
Line 382 
Line 387 
 {  {
     arg_len = arg_size = 0;      arg_len = arg_size = 0;
   
     yylval.command.cmnd = (char *) malloc(len + 1);      yylval.command.cmnd = (char *) malloc(++len);
     if (yylval.command.cmnd == NULL)      if (yylval.command.cmnd == NULL) {
         yyerror("unable to allocate memory");          yyerror("unable to allocate memory");
           return;
       }
   
     /* copy the string and NULL-terminate it (escapes handled by fnmatch) */      /* copy the string and NULL-terminate it (escapes handled by fnmatch) */
     (void) strncpy(yylval.command.cmnd, s, len);      (void) strlcpy(yylval.command.cmnd, s, len);
     yylval.command.cmnd[len] = '\0';  
   
     yylval.command.args = NULL;      yylval.command.args = NULL;
 }  }
Line 402 
Line 408 
     int new_len;      int new_len;
     char *p;      char *p;
   
     /*  
      * If first arg, malloc() some room, else if we don't  
      * have enough space realloc() some more.  
      */  
     if (yylval.command.args == NULL) {      if (yylval.command.args == NULL) {
         addspace = 0;          addspace = 0;
         new_len = len;          new_len = len;
       } else
           new_len = arg_len + len + addspace;
   
       if (new_len >= arg_size) {
           /* Allocate more space than we need for subsequent args */
         while (new_len >= (arg_size += COMMANDARGINC))          while (new_len >= (arg_size += COMMANDARGINC))
             ;              ;
   
         yylval.command.args = (char *) malloc(arg_size);          p = yylval.command.args ?
         if (yylval.command.args == NULL)              (char *) realloc(yylval.command.args, arg_size) :
             yyerror("unable to allocate memory");              (char *) malloc(arg_size);
     } else {          if (p == NULL) {
         new_len = arg_len + len + addspace;              if (yylval.command.args != NULL)
   
         if (new_len >= arg_size) {  
             /* Allocate more space than we need for subsequent args */  
             while (new_len >= (arg_size += COMMANDARGINC))  
                 ;  
   
             if ((p = (char *) realloc(yylval.command.args, arg_size)) == NULL) {  
                 free(yylval.command.args);                  free(yylval.command.args);
                 yyerror("unable to allocate memory");              yyerror("unable to allocate memory");
             } else              return;
                 yylval.command.args = p;          } else
         }              yylval.command.args = p;
     }      }
   
     /* Efficiently append the arg (with a leading space if needed). */      /* Efficiently append the arg (with a leading space if needed). */
     p = yylval.command.args + arg_len;      p = yylval.command.args + arg_len;
     if (addspace)      if (addspace)
         *p++ = ' ';          *p++ = ' ';
     (void) strcpy(p, s);      if (strlcpy(p, s, arg_size - (p - yylval.command.args)) != len)
           yyerror("fill_args: buffer overflow");  /* paranoia */
     arg_len = new_len;      arg_len = new_len;
 }  }
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9