From 6ea68d208e91b16d8f98430a40a6dec583dea830 Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Thu, 29 Jun 2023 14:37:39 -0400 Subject: [PATCH] Regenerate toke.c using updated flex Use the current version of flex to generate toke.c --- plugins/sudoers/toke.c | 885 ++++++++++++++++++++++++++--------------- plugins/sudoers/toke.l | 35 +- 2 files changed, 583 insertions(+), 337 deletions(-) diff --git a/plugins/sudoers/toke.c b/plugins/sudoers/toke.c index 700589ad3..053cba0f7 100644 --- a/plugins/sudoers/toke.c +++ b/plugins/sudoers/toke.c @@ -5,21 +5,25 @@ #include -#line 3 "toke.c" +#line 2 "toke.c" #define YY_INT_ALIGNED short int -/* $OpenBSD: flex.skl,v 1.18 2021/11/30 15:50:06 millert Exp $ */ - /* A lexical scanner generated by flex */ #define yy_create_buffer sudoers_create_buffer #define yy_delete_buffer sudoers_delete_buffer -#define yy_flex_debug sudoers_flex_debug +#define yy_scan_buffer sudoers_scan_buffer +#define yy_scan_string sudoers_scan_string +#define yy_scan_bytes sudoers_scan_bytes #define yy_init_buffer sudoers_init_buffer #define yy_flush_buffer sudoers_flush_buffer #define yy_load_buffer_state sudoers_load_buffer_state #define yy_switch_to_buffer sudoers_switch_to_buffer +#define yypush_buffer_state sudoerspush_buffer_state +#define yypop_buffer_state sudoerspop_buffer_state +#define yyensure_buffer_stack sudoersensure_buffer_stack +#define yy_flex_debug sudoers_flex_debug #define yyin sudoersin #define yyleng sudoersleng #define yylex sudoerslex @@ -34,12 +38,246 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 39 +#define YY_FLEX_MINOR_VERSION 6 +#define YY_FLEX_SUBMINOR_VERSION 4 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif +#ifdef yy_create_buffer +#define sudoers_create_buffer_ALREADY_DEFINED +#else +#define yy_create_buffer sudoers_create_buffer +#endif + +#ifdef yy_delete_buffer +#define sudoers_delete_buffer_ALREADY_DEFINED +#else +#define yy_delete_buffer sudoers_delete_buffer +#endif + +#ifdef yy_scan_buffer +#define sudoers_scan_buffer_ALREADY_DEFINED +#else +#define yy_scan_buffer sudoers_scan_buffer +#endif + +#ifdef yy_scan_string +#define sudoers_scan_string_ALREADY_DEFINED +#else +#define yy_scan_string sudoers_scan_string +#endif + +#ifdef yy_scan_bytes +#define sudoers_scan_bytes_ALREADY_DEFINED +#else +#define yy_scan_bytes sudoers_scan_bytes +#endif + +#ifdef yy_init_buffer +#define sudoers_init_buffer_ALREADY_DEFINED +#else +#define yy_init_buffer sudoers_init_buffer +#endif + +#ifdef yy_flush_buffer +#define sudoers_flush_buffer_ALREADY_DEFINED +#else +#define yy_flush_buffer sudoers_flush_buffer +#endif + +#ifdef yy_load_buffer_state +#define sudoers_load_buffer_state_ALREADY_DEFINED +#else +#define yy_load_buffer_state sudoers_load_buffer_state +#endif + +#ifdef yy_switch_to_buffer +#define sudoers_switch_to_buffer_ALREADY_DEFINED +#else +#define yy_switch_to_buffer sudoers_switch_to_buffer +#endif + +#ifdef yypush_buffer_state +#define sudoerspush_buffer_state_ALREADY_DEFINED +#else +#define yypush_buffer_state sudoerspush_buffer_state +#endif + +#ifdef yypop_buffer_state +#define sudoerspop_buffer_state_ALREADY_DEFINED +#else +#define yypop_buffer_state sudoerspop_buffer_state +#endif + +#ifdef yyensure_buffer_stack +#define sudoersensure_buffer_stack_ALREADY_DEFINED +#else +#define yyensure_buffer_stack sudoersensure_buffer_stack +#endif + +#ifdef yylex +#define sudoerslex_ALREADY_DEFINED +#else +#define yylex sudoerslex +#endif + +#ifdef yyrestart +#define sudoersrestart_ALREADY_DEFINED +#else +#define yyrestart sudoersrestart +#endif + +#ifdef yylex_init +#define sudoerslex_init_ALREADY_DEFINED +#else +#define yylex_init sudoerslex_init +#endif + +#ifdef yylex_init_extra +#define sudoerslex_init_extra_ALREADY_DEFINED +#else +#define yylex_init_extra sudoerslex_init_extra +#endif + +#ifdef yylex_destroy +#define sudoerslex_destroy_ALREADY_DEFINED +#else +#define yylex_destroy sudoerslex_destroy +#endif + +#ifdef yyget_debug +#define sudoersget_debug_ALREADY_DEFINED +#else +#define yyget_debug sudoersget_debug +#endif + +#ifdef yyset_debug +#define sudoersset_debug_ALREADY_DEFINED +#else +#define yyset_debug sudoersset_debug +#endif + +#ifdef yyget_extra +#define sudoersget_extra_ALREADY_DEFINED +#else +#define yyget_extra sudoersget_extra +#endif + +#ifdef yyset_extra +#define sudoersset_extra_ALREADY_DEFINED +#else +#define yyset_extra sudoersset_extra +#endif + +#ifdef yyget_in +#define sudoersget_in_ALREADY_DEFINED +#else +#define yyget_in sudoersget_in +#endif + +#ifdef yyset_in +#define sudoersset_in_ALREADY_DEFINED +#else +#define yyset_in sudoersset_in +#endif + +#ifdef yyget_out +#define sudoersget_out_ALREADY_DEFINED +#else +#define yyget_out sudoersget_out +#endif + +#ifdef yyset_out +#define sudoersset_out_ALREADY_DEFINED +#else +#define yyset_out sudoersset_out +#endif + +#ifdef yyget_leng +#define sudoersget_leng_ALREADY_DEFINED +#else +#define yyget_leng sudoersget_leng +#endif + +#ifdef yyget_text +#define sudoersget_text_ALREADY_DEFINED +#else +#define yyget_text sudoersget_text +#endif + +#ifdef yyget_lineno +#define sudoersget_lineno_ALREADY_DEFINED +#else +#define yyget_lineno sudoersget_lineno +#endif + +#ifdef yyset_lineno +#define sudoersset_lineno_ALREADY_DEFINED +#else +#define yyset_lineno sudoersset_lineno +#endif + +#ifdef yywrap +#define sudoerswrap_ALREADY_DEFINED +#else +#define yywrap sudoerswrap +#endif + +#ifdef yyalloc +#define sudoersalloc_ALREADY_DEFINED +#else +#define yyalloc sudoersalloc +#endif + +#ifdef yyrealloc +#define sudoersrealloc_ALREADY_DEFINED +#else +#define yyrealloc sudoersrealloc +#endif + +#ifdef yyfree +#define sudoersfree_ALREADY_DEFINED +#else +#define yyfree sudoersfree +#endif + +#ifdef yytext +#define sudoerstext_ALREADY_DEFINED +#else +#define yytext sudoerstext +#endif + +#ifdef yyleng +#define sudoersleng_ALREADY_DEFINED +#else +#define yyleng sudoersleng +#endif + +#ifdef yyin +#define sudoersin_ALREADY_DEFINED +#else +#define yyin sudoersin +#endif + +#ifdef yyout +#define sudoersout_ALREADY_DEFINED +#else +#define yyout sudoersout +#endif + +#ifdef yy_flex_debug +#define sudoers_flex_debug_ALREADY_DEFINED +#else +#define yy_flex_debug sudoers_flex_debug +#endif + +#ifdef yylineno +#define sudoerslineno_ALREADY_DEFINED +#else +#define yylineno sudoerslineno +#endif + /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ @@ -50,8 +288,6 @@ /* end standard C headers. */ -/* $OpenBSD: flexint.h,v 1.1 2015/11/19 19:43:40 tedu Exp $ */ - /* flex integer type definitions */ #ifndef FLEXINT_H @@ -112,65 +348,61 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + #endif /* ! C99 */ #endif /* ! FLEXINT_H */ -#ifdef __cplusplus +/* begin standard C++ headers. */ -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST +/* TODO: this is always defined, so inline it */ #define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) #else -#define yyconst +#define yynoreturn #endif /* Returned upon end-of-file. */ #define YY_NULL 0 -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * - /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START - /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - /* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE sudoersrestart(sudoersin ) - +#define YY_NEW_FILE yyrestart( yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -187,14 +419,14 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; typedef size_t yy_size_t; #endif -extern yy_size_t sudoersleng; +extern int yyleng; -extern FILE *sudoersin, *sudoersout; +extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 - + #define YY_LESS_LINENO(n) #define YY_LINENO_REWIND_TO(ptr) @@ -202,16 +434,15 @@ extern FILE *sudoersin, *sudoersout; #define yyless(n) \ do \ { \ - /* Undo effects of setting up sudoerstext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up sudoerstext again */ \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) - #define unput(c) yyunput( c, (yytext_ptr) ) #ifndef YY_STRUCT_YY_BUFFER_STATE @@ -226,12 +457,12 @@ struct yy_buffer_state /* Size of input buffer in bytes, not including room for EOB * characters. */ - yy_size_t yy_buf_size; + int yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - yy_size_t yy_n_chars; + int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -254,7 +485,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -271,8 +502,8 @@ struct yy_buffer_state * possible backing-up. * * When we actually see the EOF, we change the status to "new" - * (via sudoersrestart()), so that the user can continue scanning by - * just pointing sudoersin at a new input file. + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 @@ -282,7 +513,7 @@ struct yy_buffer_state /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -293,106 +524,101 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) - /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] -/* yy_hold_char holds the character lost when sudoerstext is formed. */ +/* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t sudoersleng; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ -/* Flag which is used to allow sudoerswrap()'s to do buffer switches - * instead of setting up a fresh sudoersin. A bit of a hack ... +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; -void sudoersrestart (FILE *input_file ); -void sudoers_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE sudoers_create_buffer (FILE *file,int size ); -void sudoers_delete_buffer (YY_BUFFER_STATE b ); -void sudoers_flush_buffer (YY_BUFFER_STATE b ); -void sudoerspush_buffer_state (YY_BUFFER_STATE new_buffer ); -void sudoerspop_buffer_state (void ); +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); -static void sudoersensure_buffer_stack (void ); -static void sudoers_load_buffer_state (void ); -static void sudoers_init_buffer (YY_BUFFER_STATE b,FILE *file ); +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) -#define YY_FLUSH_BUFFER sudoers_flush_buffer(YY_CURRENT_BUFFER ) +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); -YY_BUFFER_STATE sudoers_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE sudoers_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE sudoers_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *sudoersalloc (yy_size_t ); -void *sudoersrealloc (void *,yy_size_t ); -void sudoersfree (void * ); - -#define yy_new_buffer sudoers_create_buffer +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); +#define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ - sudoersensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - sudoers_create_buffer(sudoersin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } - #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ - sudoersensure_buffer_stack (); \ + yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ - sudoers_create_buffer(sudoersin,YY_BUF_SIZE ); \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } - #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ -#define sudoerswrap() 1 +#define sudoerswrap() (/*CONSTCOND*/1) #define YY_SKIP_YYWRAP +typedef flex_uint8_t YY_CHAR; -typedef unsigned char YY_CHAR; - -FILE *sudoersin = (FILE *) 0, *sudoersout = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; -extern int sudoerslineno; +extern int yylineno; +int yylineno = 1; -int sudoerslineno = 1; +extern char *yytext; +#ifdef yytext_ptr +#undef yytext_ptr +#endif +#define yytext_ptr yytext -extern char *sudoerstext; -#define yytext_ptr sudoerstext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); /* Done after the current pattern has been matched and before the - * corresponding action - sets up sudoerstext. + * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ - sudoersleng = (size_t) (yy_cp - yy_bp); \ + yyleng = (int) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; - #define YY_NUM_RULES 89 #define YY_END_OF_BUFFER 90 /* This struct is not used in this scanner, @@ -402,7 +628,7 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[1242] = +static const flex_int16_t yy_accept[1242] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -543,7 +769,7 @@ static yyconst flex_int16_t yy_accept[1242] = 0 } ; -static yyconst flex_int32_t yy_ec[256] = +static const YY_CHAR yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 4, 5, 1, 1, 1, 1, 1, 1, 1, @@ -575,7 +801,7 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[77] = +static const YY_CHAR yy_meta[77] = { 0, 1, 2, 3, 4, 3, 2, 5, 6, 7, 8, 1, 9, 9, 1, 10, 11, 1, 12, 13, 14, @@ -587,7 +813,7 @@ static yyconst flex_int32_t yy_meta[77] = 21, 21, 21, 21, 21, 21 } ; -static yyconst flex_int16_t yy_base[1366] = +static const flex_int16_t yy_base[1366] = { 0, 0, 75, 126, 199, 83, 91, 99, 180, 272, 347, 422, 478, 131, 147, 535, 0, 189, 219, 611, 0, @@ -741,7 +967,7 @@ static yyconst flex_int16_t yy_base[1366] = 9492, 6988, 5690, 9512, 3664 } ; -static yyconst flex_int16_t yy_def[1366] = +static const flex_int16_t yy_def[1366] = { 0, 1241, 1, 1, 1, 1242, 1242, 1243, 1243, 1244, 1244, 1245, 1245, 1246, 1246, 1241, 15, 1247, 1247, 1241, 19, @@ -895,7 +1121,7 @@ static yyconst flex_int16_t yy_def[1366] = 1241, 1241, 1241, 1241, 1241 } ; -static yyconst flex_int16_t yy_nxt[9611] = +static const flex_int16_t yy_nxt[9611] = { 0, 22, 23, 24, 22, 25, 23, 26, 27, 28, 22, 29, 30, 31, 22, 32, 33, 22, 22, 34, 35, @@ -1956,7 +2182,7 @@ static yyconst flex_int16_t yy_nxt[9611] = 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241 } ; -static yyconst flex_int16_t yy_chk[9611] = +static const flex_int16_t yy_chk[9611] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -3020,8 +3246,8 @@ static yyconst flex_int16_t yy_chk[9611] = static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; -extern int sudoers_flex_debug; -int sudoers_flex_debug = 0; +extern int yy_flex_debug; +int yy_flex_debug = 0; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -3030,7 +3256,7 @@ int sudoers_flex_debug = 0; #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET -char *sudoerstext; +char *yytext; #line 1 "toke.l" #line 2 "toke.l" /* @@ -3120,17 +3346,10 @@ int (*trace_print)(const char *msg) = sudoers_trace_print; yyless(n); \ } while (0); +#line 3343 "toke.c" #define YY_NO_INPUT 1 - - - - - - - - -#line 3128 "toke.c" +#line 3346 "toke.c" #define INITIAL 0 #define GOTDEFS 1 @@ -3155,36 +3374,36 @@ int (*trace_print)(const char *msg) = sudoers_trace_print; #define YY_EXTRA_TYPE void * #endif -static int yy_init_globals (void ); +static int yy_init_globals ( void ); /* Accessor methods to globals. These are made visible to non-reentrant scanners for convenience. */ -int sudoerslex_destroy (void ); +int yylex_destroy ( void ); -int sudoersget_debug (void ); +int yyget_debug ( void ); -void sudoersset_debug (int debug_flag ); +void yyset_debug ( int debug_flag ); -YY_EXTRA_TYPE sudoersget_extra (void ); +YY_EXTRA_TYPE yyget_extra ( void ); -void sudoersset_extra (YY_EXTRA_TYPE user_defined ); +void yyset_extra ( YY_EXTRA_TYPE user_defined ); -FILE *sudoersget_in (void ); +FILE *yyget_in ( void ); -void sudoersset_in (FILE * in_str ); +void yyset_in ( FILE * _in_str ); -FILE *sudoersget_out (void ); +FILE *yyget_out ( void ); -void sudoersset_out (FILE * out_str ); +void yyset_out ( FILE * _out_str ); -yy_size_t sudoersget_leng (void ); + int yyget_leng ( void ); -char *sudoersget_text (void ); +char *yyget_text ( void ); -int sudoersget_lineno (void ); +int yyget_lineno ( void ); -void sudoersset_lineno (int line_number ); +void yyset_lineno ( int _line_number ); /* Macros after this point can all be overridden by user definitions in * section 1. @@ -3192,33 +3411,41 @@ void sudoersset_lineno (int line_number ); #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus -extern "C" int sudoerswrap (void ); +extern "C" int yywrap ( void ); #else -extern int sudoerswrap (void ); +extern int yywrap ( void ); #endif #endif +#ifndef YY_NO_UNPUT + +#endif + #ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); +static void yy_flex_strncpy ( char *, const char *, int ); #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); +static int yy_flex_strlen ( const char * ); #endif #ifndef YY_NO_INPUT - #ifdef __cplusplus -static int yyinput (void ); +static int yyinput ( void ); #else -static int input (void ); +static int input ( void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -3226,7 +3453,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( sudoerstext, sudoersleng, 1, sudoersout )) {} } while (0) +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -3237,20 +3464,20 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - size_t n; \ + int n; \ for ( n = 0; n < max_size && \ - (c = getc( sudoersin )) != EOF && c != '\n'; ++n ) \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ - if ( c == EOF && ferror( sudoersin ) ) \ + if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ - while ( (result = fread(buf, 1, max_size, sudoersin))==0 && ferror(sudoersin)) \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ @@ -3258,7 +3485,7 @@ static int input (void ); break; \ } \ errno=0; \ - clearerr(sudoersin); \ + clearerr(yyin); \ } \ }\ \ @@ -3291,12 +3518,12 @@ static int input (void ); #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int sudoerslex (void); +extern int yylex (void); -#define YY_DECL int sudoerslex (void) +#define YY_DECL int yylex (void) #endif /* !YY_DECL */ -/* Code executed at the beginning of each rule, after sudoerstext and sudoersleng +/* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION @@ -3305,13 +3532,13 @@ extern int sudoerslex (void); /* Code executed at the end of each rule. */ #ifndef YY_BREAK -#define YY_BREAK break; +#define YY_BREAK /*LINTED*/break; #endif #define YY_RULE_SETUP \ - if ( sudoersleng > 0 ) \ + if ( yyleng > 0 ) \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (sudoerstext[sudoersleng - 1] == '\n'); \ + (yytext[yyleng - 1] == '\n'); \ YY_USER_ACTION /** The main scanner function which does all the work. @@ -3333,33 +3560,31 @@ YY_DECL if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ - if ( ! sudoersin ) { - sudoersin = stdin; - } + if ( ! yyin ) + yyin = stdin; - if ( ! sudoersout ) { - sudoersout = stdout; - } + if ( ! yyout ) + yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { - sudoersensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - sudoers_create_buffer(sudoersin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - sudoers_load_buffer_state( ); - } + yy_load_buffer_state( ); + } { #line 119 "toke.l" -#line 3351 "toke.c" +#line 3575 "toke.c" - while ( 1 ) /* loops until end-of-file is reached */ + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); - /* Support of sudoerstext. */ + /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of @@ -3382,9 +3607,9 @@ yy_match: { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 1242 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 9534 ); @@ -3794,7 +4019,7 @@ YY_RULE_SETUP #line 412 "toke.l" { char deftype; - int n; + size_t n; if (continued) { sudoers_errstr = N_("invalid line continuation"); @@ -3837,7 +4062,7 @@ case 29: YY_RULE_SETUP #line 453 "toke.l" { - int n; + size_t n; if (continued) { sudoers_errstr = N_("invalid line continuation"); @@ -4490,7 +4715,7 @@ YY_RULE_SETUP #line 909 "toke.l" ECHO; YY_BREAK -#line 4488 "toke.c" +#line 4712 "toke.c" case YY_END_OF_BUFFER: { @@ -4505,15 +4730,15 @@ ECHO; { /* We're scanning a new file or input source. It's * possible that this happened because the user - * just pointed sudoersin at a new source and called - * sudoerslex(). If so, then we have to assure + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = sudoersin; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } @@ -4566,11 +4791,11 @@ ECHO; { (yy_did_buffer_switch_on_eof) = 0; - if ( sudoerswrap( ) ) + if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up - * sudoerstext, we can now set up + * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the @@ -4620,7 +4845,7 @@ ECHO; } /* end of action switch */ } /* end of scanning one token */ } /* end of user's declarations */ -} /* end of sudoerslex */ +} /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * @@ -4662,7 +4887,7 @@ static int yy_get_next_buffer (void) /* Try to read more data. */ /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); @@ -4675,7 +4900,7 @@ static int yy_get_next_buffer (void) else { - yy_size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -4689,7 +4914,7 @@ static int yy_get_next_buffer (void) if ( b->yy_is_our_buffer ) { - yy_size_t new_size = b->yy_buf_size * 2; + int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -4698,11 +4923,12 @@ static int yy_get_next_buffer (void) b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ - sudoersrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = NULL; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -4730,7 +4956,7 @@ static int yy_get_next_buffer (void) if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; - sudoersrestart(sudoersin ); + yyrestart( yyin ); } else @@ -4744,10 +4970,11 @@ static int yy_get_next_buffer (void) else ret_val = EOB_ACT_CONTINUE_SCAN; - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) sudoersrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); /* "- 2" to take care of EOB's */ @@ -4785,9 +5012,9 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 1242 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; } return yy_current_state; @@ -4813,14 +5040,18 @@ static int yy_get_next_buffer (void) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 1242 ) - yy_c = yy_meta[(unsigned int) yy_c]; + yy_c = yy_meta[yy_c]; } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; yy_is_jam = (yy_current_state == 1241); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } +#ifndef YY_NO_UNPUT + +#endif + #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) @@ -4845,7 +5076,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -4862,14 +5093,14 @@ static int yy_get_next_buffer (void) */ /* Reset buffer status. */ - sudoersrestart(sudoersin ); + yyrestart( yyin ); FALLTHROUGH; case EOB_ACT_END_OF_FILE: { - if ( sudoerswrap( ) ) - return EOF; + if ( yywrap( ) ) + return 0; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; @@ -4888,7 +5119,7 @@ static int yy_get_next_buffer (void) } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve sudoerstext */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); @@ -4902,32 +5133,32 @@ static int yy_get_next_buffer (void) * * @note This function does not reset the start condition to @c INITIAL . */ - void sudoersrestart (FILE * input_file ) + void yyrestart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ - sudoersensure_buffer_stack (); + yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = - sudoers_create_buffer(sudoersin,YY_BUF_SIZE ); + yy_create_buffer( yyin, YY_BUF_SIZE ); } - sudoers_init_buffer(YY_CURRENT_BUFFER,input_file ); - sudoers_load_buffer_state( ); + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ - void sudoers_switch_to_buffer (YY_BUFFER_STATE new_buffer ) + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with - * sudoerspop_buffer_state(); - * sudoerspush_buffer_state(new_buffer); + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); */ - sudoersensure_buffer_stack (); + yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; @@ -4940,21 +5171,21 @@ static int yy_get_next_buffer (void) } YY_CURRENT_BUFFER_LVALUE = new_buffer; - sudoers_load_buffer_state( ); + yy_load_buffer_state( ); /* We don't actually know whether we did this switch during - * EOF (sudoerswrap()) processing, but the only time this flag - * is looked at is after sudoerswrap() is called, so it's safe + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } -static void sudoers_load_buffer_state (void) +static void yy_load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - sudoersin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } @@ -4964,35 +5195,35 @@ static void sudoers_load_buffer_state (void) * * @return the allocated buffer state. */ - YY_BUFFER_STATE sudoers_create_buffer (FILE * file, int size ) + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; - b = (YY_BUFFER_STATE) sudoersalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in sudoers_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ - b->yy_ch_buf = (char *) sudoersalloc(b->yy_buf_size + 2 ); + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in sudoers_create_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; - sudoers_init_buffer(b,file ); + yy_init_buffer( b, file ); return b; } /** Destroy the buffer. - * @param b a buffer created with sudoers_create_buffer() + * @param b a buffer created with yy_create_buffer() * */ - void sudoers_delete_buffer (YY_BUFFER_STATE b ) + void yy_delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) @@ -5002,27 +5233,27 @@ static void sudoers_load_buffer_state (void) YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) - sudoersfree((void *) b->yy_ch_buf ); + yyfree( (void *) b->yy_ch_buf ); - sudoersfree((void *) b ); + yyfree( (void *) b ); } /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, - * such as during a sudoersrestart() or at EOF. + * such as during a yyrestart() or at EOF. */ - static void sudoers_init_buffer (YY_BUFFER_STATE b, FILE * file ) + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; - sudoers_flush_buffer(b ); + yy_flush_buffer( b ); b->yy_input_file = file; b->yy_fill_buffer = 1; - /* If b is the current buffer, then sudoers_init_buffer was _probably_ - * called from sudoersrestart() or through yy_get_next_buffer. + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ @@ -5039,7 +5270,7 @@ static void sudoers_load_buffer_state (void) * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ - void sudoers_flush_buffer (YY_BUFFER_STATE b ) + void yy_flush_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; @@ -5059,7 +5290,7 @@ static void sudoers_load_buffer_state (void) b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) - sudoers_load_buffer_state( ); + yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes @@ -5068,14 +5299,14 @@ static void sudoers_load_buffer_state (void) * @param new_buffer The new state. * */ -void sudoerspush_buffer_state (YY_BUFFER_STATE new_buffer ) +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; - sudoersensure_buffer_stack(); + yyensure_buffer_stack(); - /* This block is copied from sudoers_switch_to_buffer. */ + /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ @@ -5089,8 +5320,8 @@ void sudoerspush_buffer_state (YY_BUFFER_STATE new_buffer ) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; - /* copied from sudoers_switch_to_buffer. */ - sudoers_load_buffer_state( ); + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } @@ -5098,18 +5329,18 @@ void sudoerspush_buffer_state (YY_BUFFER_STATE new_buffer ) * The next element becomes the new top. * */ -void sudoerspop_buffer_state (void) +void yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; - sudoers_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { - sudoers_load_buffer_state( ); + yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } @@ -5117,7 +5348,7 @@ void sudoerspop_buffer_state (void) /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ -static void sudoersensure_buffer_stack (void) +static void yyensure_buffer_stack (void) { yy_size_t num_to_alloc; @@ -5127,15 +5358,15 @@ static void sudoersensure_buffer_stack (void) * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)sudoersalloc + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in sudoersensure_buffer_stack()" ); - + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -5144,15 +5375,15 @@ static void sudoersensure_buffer_stack (void) if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; + yy_size_t grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)sudoersrealloc + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in sudoersensure_buffer_stack()" ); + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); @@ -5164,9 +5395,9 @@ static void sudoersensure_buffer_stack (void) * @param base the character buffer * @param size the size in bytes of the character buffer * - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE sudoers_scan_buffer (char * base, yy_size_t size ) +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; @@ -5174,69 +5405,69 @@ YY_BUFFER_STATE sudoers_scan_buffer (char * base, yy_size_t size ) base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return NULL; - b = (YY_BUFFER_STATE) sudoersalloc(sizeof( struct yy_buffer_state ) ); + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in sudoers_scan_buffer()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = NULL; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; - sudoers_switch_to_buffer(b ); + yy_switch_to_buffer( b ); return b; } -/** Setup the input buffer state to scan a string. The next call to sudoerslex() will +/** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use - * sudoers_scan_bytes() instead. + * yy_scan_bytes() instead. */ -YY_BUFFER_STATE sudoers_scan_string (yyconst char * yystr ) +YY_BUFFER_STATE yy_scan_string (const char * yystr ) { - return sudoers_scan_bytes(yystr,strlen(yystr) ); + return yy_scan_bytes( yystr, (int) strlen(yystr) ); } -/** Setup the input buffer state to scan the given bytes. The next call to sudoerslex() will +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param yybytes the byte buffer to scan * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE sudoers_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - yy_size_t i; + int i; /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) sudoersalloc(n ); + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in sudoers_scan_bytes()" ); + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - b = sudoers_scan_buffer(buf,n ); + b = yy_scan_buffer( buf, n ); if ( ! b ) - YY_FATAL_ERROR( "bad buffer in sudoers_scan_bytes()" ); + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. @@ -5250,9 +5481,9 @@ YY_BUFFER_STATE sudoers_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes #define YY_EXIT_FAILURE 2 #endif -static void yy_fatal_error (yyconst char* msg ) +static void yynoreturn yy_fatal_error (const char* msg ) { - (void) fprintf( stderr, "%s\n", msg ); + fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } @@ -5262,14 +5493,14 @@ static void yy_fatal_error (yyconst char* msg ) #define yyless(n) \ do \ { \ - /* Undo effects of setting up sudoerstext. */ \ + /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ - sudoerstext[sudoersleng] = (yy_hold_char); \ - (yy_c_buf_p) = sudoerstext + yyless_macro_arg; \ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ - sudoersleng = yyless_macro_arg; \ + yyleng = yyless_macro_arg; \ } \ while ( 0 ) @@ -5278,126 +5509,126 @@ static void yy_fatal_error (yyconst char* msg ) /** Get the current line number. * */ -int sudoersget_lineno (void) +int yyget_lineno (void) { - - return sudoerslineno; + + return yylineno; } /** Get the input stream. * */ -FILE *sudoersget_in (void) +FILE *yyget_in (void) { - return sudoersin; + return yyin; } /** Get the output stream. * */ -FILE *sudoersget_out (void) +FILE *yyget_out (void) { - return sudoersout; + return yyout; } /** Get the length of the current token. * */ -yy_size_t sudoersget_leng (void) +int yyget_leng (void) { - return sudoersleng; + return yyleng; } /** Get the current token. * */ -char *sudoersget_text (void) +char *yyget_text (void) { - return sudoerstext; + return yytext; } /** Set the current line number. - * @param line_number + * @param _line_number line number * */ -void sudoersset_lineno (int line_number ) +void yyset_lineno (int _line_number ) { - sudoerslineno = line_number; + yylineno = _line_number; } /** Set the input stream. This does not discard the current * input buffer. - * @param in_str A readable stream. + * @param _in_str A readable stream. * - * @see sudoers_switch_to_buffer + * @see yy_switch_to_buffer */ -void sudoersset_in (FILE * in_str ) +void yyset_in (FILE * _in_str ) { - sudoersin = in_str ; + yyin = _in_str ; } -void sudoersset_out (FILE * out_str ) +void yyset_out (FILE * _out_str ) { - sudoersout = out_str ; + yyout = _out_str ; } -int sudoersget_debug (void) +int yyget_debug (void) { - return sudoers_flex_debug; + return yy_flex_debug; } -void sudoersset_debug (int bdebug ) +void yyset_debug (int _bdebug ) { - sudoers_flex_debug = bdebug ; + yy_flex_debug = _bdebug ; } static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. - * This function is called from sudoerslex_destroy(), so don't allocate here. + * This function is called from yylex_destroy(), so don't allocate here. */ - (yy_buffer_stack) = 0; + (yy_buffer_stack) = NULL; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; + (yy_c_buf_p) = NULL; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT - sudoersin = stdin; - sudoersout = stdout; + yyin = stdin; + yyout = stdout; #else - sudoersin = (FILE *) 0; - sudoersout = (FILE *) 0; + yyin = NULL; + yyout = NULL; #endif /* For future reference: Set errno on error, since we are called by - * sudoerslex_init() + * yylex_init() */ return 0; } -/* sudoerslex_destroy is for both reentrant and non-reentrant scanners. */ -int sudoerslex_destroy (void) +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ - sudoers_delete_buffer(YY_CURRENT_BUFFER ); + yy_delete_buffer( YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; - sudoerspop_buffer_state(); + yypop_buffer_state(); } /* Destroy the stack itself. */ - sudoersfree((yy_buffer_stack) ); + yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time - * sudoerslex() is called, initialization will occur. */ + * yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; @@ -5408,8 +5639,9 @@ int sudoerslex_destroy (void) */ #ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +static void yy_flex_strncpy (char* s1, const char * s2, int n ) { + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; @@ -5417,7 +5649,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #endif #ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) +static int yy_flex_strlen (const char * s ) { int n; for ( n = 0; s[n]; ++n ) @@ -5427,13 +5659,14 @@ static int yy_flex_strlen (yyconst char * s ) } #endif -void *sudoersalloc (yy_size_t size ) +void *yyalloc (yy_size_t size ) { - return (void *) malloc( size ); + return malloc(size); } -void *sudoersrealloc (void * ptr, yy_size_t size ) +void *yyrealloc (void * ptr, yy_size_t size ) { + /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter @@ -5441,19 +5674,18 @@ void *sudoersrealloc (void * ptr, yy_size_t size ) * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ - return (void *) realloc( (char *) ptr, size ); + return realloc(ptr, size); } -void sudoersfree (void * ptr ) +void yyfree (void * ptr ) { - free( (char *) ptr ); /* see sudoersrealloc() for (char *) cast */ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 909 "toke.l" - struct path_list { SLIST_ENTRY(path_list) entries; char *path; @@ -5489,12 +5721,12 @@ pl_compare(const void *v1, const void *v2) * Returns the number of files or -1 on error. * If zero files are found, NULL is stored in pathsp. */ -static int +static size_t read_dir_files(const char *dirpath, struct path_list ***pathsp, int verbose) { DIR *dir; - int i, count = 0; - int max_paths = 32; + size_t i, count = 0; + size_t max_paths = 32; struct dirent *dent; struct path_list **paths = NULL; const size_t dirlen = strlen(dirpath); @@ -5573,7 +5805,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp, int verbose) } done: *pathsp = paths; - debug_return_int(count); + debug_return_size_t(count); oom: sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); bad: @@ -5585,18 +5817,18 @@ bad: free(paths[i]); } free(paths); - debug_return_int(-1); + debug_return_size_t(-1); } /* * Push a list of all files in dirpath onto stack. * Returns the number of files or -1 on error. */ -static int +static size_t switch_dir(struct include_stack *stack, char *dirpath, int verbose) { struct path_list **paths = NULL; - int count, i; + size_t count, i; debug_decl(switch_dir, SUDOERS_DEBUG_PARSER); count = read_dir_files(dirpath, &paths, verbose); @@ -5611,7 +5843,7 @@ switch_dir(struct include_stack *stack, char *dirpath, int verbose) free(paths); } - debug_return_int(count); + debug_return_size_t(count); } #define MAX_SUDOERS_DEPTH 128 @@ -5709,7 +5941,7 @@ expand_include(const char *src) const char *cp, *ep; char *dst0, *dst; size_t dst_size, src_len; - unsigned int nhost = 0; + size_t nhost = 0; debug_decl(expand_include, SUDOERS_DEBUG_PARSER); /* Strip double quotes if present. */ @@ -5853,7 +6085,8 @@ push_include_int(const char *opath, bool isdir, int verbose) if (isdir) { struct stat sb; char dname[PATH_MAX]; - int count, fd, status; + int fd, status; + size_t count; fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL); status = sudo_secure_fd(fd, S_IFDIR, sudoers_file_uid(), @@ -5889,10 +6122,16 @@ push_include_int(const char *opath, bool isdir, int verbose) debug_return_bool(true); } count = switch_dir(&istack[idepth], dname, verbose); - if (count <= 0) { + if (count == 0) { /* switch_dir() called sudoerserror() for us */ sudo_rcstr_delref(path); - debug_return_bool(count ? false : true); + debug_return_bool(true); + } + + if (count == (size_t)-1) { + /* switch_dir() called sudoerserror() for us */ + sudo_rcstr_delref(path); + debug_return_bool(false); } /* Parse the first dir entry we can open, leave the rest for later. */ diff --git a/plugins/sudoers/toke.l b/plugins/sudoers/toke.l index 548b111b3..b24549d7d 100644 --- a/plugins/sudoers/toke.l +++ b/plugins/sudoers/toke.l @@ -411,7 +411,7 @@ DEFVAR [a-z_]+ ^[[:blank:]]*Defaults([:@>\!][[:blank:]]*\!*\"?({ID}|{WORD}))? { char deftype; - int n; + size_t n; if (continued) { sudoers_errstr = N_("invalid line continuation"); @@ -451,7 +451,7 @@ DEFVAR [a-z_]+ } ^[[:blank:]]*(Host|Cmnd|Cmd|User|Runas)_Alias { - int n; + size_t n; if (continued) { sudoers_errstr = N_("invalid line continuation"); @@ -942,12 +942,12 @@ pl_compare(const void *v1, const void *v2) * Returns the number of files or -1 on error. * If zero files are found, NULL is stored in pathsp. */ -static int +static size_t read_dir_files(const char *dirpath, struct path_list ***pathsp, int verbose) { DIR *dir; - int i, count = 0; - int max_paths = 32; + size_t i, count = 0; + size_t max_paths = 32; struct dirent *dent; struct path_list **paths = NULL; const size_t dirlen = strlen(dirpath); @@ -1026,7 +1026,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp, int verbose) } done: *pathsp = paths; - debug_return_int(count); + debug_return_size_t(count); oom: sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory")); bad: @@ -1038,18 +1038,18 @@ bad: free(paths[i]); } free(paths); - debug_return_int(-1); + debug_return_size_t(-1); } /* * Push a list of all files in dirpath onto stack. * Returns the number of files or -1 on error. */ -static int +static size_t switch_dir(struct include_stack *stack, char *dirpath, int verbose) { struct path_list **paths = NULL; - int count, i; + size_t count, i; debug_decl(switch_dir, SUDOERS_DEBUG_PARSER); count = read_dir_files(dirpath, &paths, verbose); @@ -1064,7 +1064,7 @@ switch_dir(struct include_stack *stack, char *dirpath, int verbose) free(paths); } - debug_return_int(count); + debug_return_size_t(count); } #define MAX_SUDOERS_DEPTH 128 @@ -1162,7 +1162,7 @@ expand_include(const char *src) const char *cp, *ep; char *dst0, *dst; size_t dst_size, src_len; - unsigned int nhost = 0; + size_t nhost = 0; debug_decl(expand_include, SUDOERS_DEBUG_PARSER); /* Strip double quotes if present. */ @@ -1306,7 +1306,8 @@ push_include_int(const char *opath, bool isdir, int verbose) if (isdir) { struct stat sb; char dname[PATH_MAX]; - int count, fd, status; + int fd, status; + size_t count; fd = sudo_open_conf_path(path, dname, sizeof(dname), NULL); status = sudo_secure_fd(fd, S_IFDIR, sudoers_file_uid(), @@ -1342,10 +1343,16 @@ push_include_int(const char *opath, bool isdir, int verbose) debug_return_bool(true); } count = switch_dir(&istack[idepth], dname, verbose); - if (count <= 0) { + if (count == 0) { /* switch_dir() called sudoerserror() for us */ sudo_rcstr_delref(path); - debug_return_bool(count ? false : true); + debug_return_bool(true); + } + + if (count == (size_t)-1) { + /* switch_dir() called sudoerserror() for us */ + sudo_rcstr_delref(path); + debug_return_bool(false); } /* Parse the first dir entry we can open, leave the rest for later. */