Fix compiler warnings on some platforms and provide a better method

of defeating gcc's warn_unused_result attribute.
This commit is contained in:
Todd C. Miller
2012-03-29 10:33:40 -04:00
parent 8393ec0501
commit aecb5206e2
11 changed files with 117 additions and 99 deletions

View File

@@ -302,7 +302,7 @@ sudo_debug_write(const char *str, int len)
iov[0].iov_len = 16; iov[0].iov_len = 16;
/* Write message in a single syscall */ /* Write message in a single syscall */
(void) writev(sudo_debug_fd, iov, iovcnt); ignore_result(writev(sudo_debug_fd, iov, iovcnt));
break; break;
} }
} }

View File

@@ -912,6 +912,15 @@
# endif /* HAVE_ST_MTIMESPEC */ # endif /* HAVE_ST_MTIMESPEC */
#endif /* HAVE_ST_MTIM */ #endif /* HAVE_ST_MTIM */
#ifdef __GNUC__
# define ignore_result(x) do { \
__typeof__(x) y = (x); \
(void)y; \
} while(0)
#else
# define ignore_result(x) (void)(x)
#endif
/* GNU stow needs /etc/sudoers to be a symlink. */ /* GNU stow needs /etc/sudoers to be a symlink. */
#ifdef USE_STOW #ifdef USE_STOW
# define stat_sudoers stat # define stat_sudoers stat

View File

@@ -468,14 +468,14 @@ io_version(int verbose)
static int static int
io_log_input(const char *buf, unsigned int len) io_log_input(const char *buf, unsigned int len)
{ {
fwrite(buf, len, 1, input); ignore_result(fwrite(buf, len, 1, input));
return true; return true;
} }
static int static int
io_log_output(const char *buf, unsigned int len) io_log_output(const char *buf, unsigned int len)
{ {
fwrite(buf, len, 1, output); ignore_result(fwrite(buf, len, 1, output));
return true; return true;
} }

View File

@@ -632,10 +632,10 @@ sudoers_io_log(const char *buf, unsigned int len, int idx)
#ifdef HAVE_ZLIB_H #ifdef HAVE_ZLIB_H
if (iolog_compress) if (iolog_compress)
gzwrite(io_fds[idx].g, (const voidp)buf, len); ignore_result(gzwrite(io_fds[idx].g, (const voidp)buf, len));
else else
#endif #endif
fwrite(buf, 1, len, io_fds[idx].f); ignore_result(fwrite(buf, 1, len, io_fds[idx].f));
delay.tv_sec = now.tv_sec; delay.tv_sec = now.tv_sec;
delay.tv_usec = now.tv_usec; delay.tv_usec = now.tv_usec;
timevalsub(&delay, &last_time); timevalsub(&delay, &last_time);

View File

@@ -1506,6 +1506,8 @@ int (*trace_print)(const char *msg) = sudoers_trace_print;
return (n); \ return (n); \
} while (0) } while (0)
#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout))
#define push_include(_p) (_push_include((_p), false)) #define push_include(_p) (_push_include((_p), false))
#define push_includedir(_p) (_push_include((_p), true)) #define push_includedir(_p) (_push_include((_p), true))
#define YY_NO_INPUT 1 #define YY_NO_INPUT 1
@@ -1520,7 +1522,7 @@ int (*trace_print)(const char *msg) = sudoers_trace_print;
#define INSTR 5 #define INSTR 5
#line 1523 "lex.yy.c" #line 1525 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in /* Macros after this point can all be overridden by user definitions in
* section 1. * section 1.
@@ -1674,9 +1676,9 @@ YY_DECL
register char *yy_cp, *yy_bp; register char *yy_cp, *yy_bp;
register int yy_act; register int yy_act;
#line 131 "toke.l" #line 133 "toke.l"
#line 1679 "lex.yy.c" #line 1681 "lex.yy.c"
if ( yy_init ) if ( yy_init )
{ {
@@ -1762,7 +1764,7 @@ do_action: /* This label is used only to access EOF actions. */
case 1: case 1:
YY_RULE_SETUP YY_RULE_SETUP
#line 132 "toke.l" #line 134 "toke.l"
{ {
LEXTRACE(", "); LEXTRACE(", ");
LEXRETURN(','); LEXRETURN(',');
@@ -1770,12 +1772,12 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 2: case 2:
YY_RULE_SETUP YY_RULE_SETUP
#line 137 "toke.l" #line 139 "toke.l"
BEGIN STARTDEFS; BEGIN STARTDEFS;
YY_BREAK YY_BREAK
case 3: case 3:
YY_RULE_SETUP YY_RULE_SETUP
#line 139 "toke.l" #line 141 "toke.l"
{ {
BEGIN INDEFS; BEGIN INDEFS;
LEXTRACE("DEFVAR "); LEXTRACE("DEFVAR ");
@@ -1787,7 +1789,7 @@ YY_RULE_SETUP
case 4: case 4:
YY_RULE_SETUP YY_RULE_SETUP
#line 148 "toke.l" #line 150 "toke.l"
{ {
BEGIN STARTDEFS; BEGIN STARTDEFS;
LEXTRACE(", "); LEXTRACE(", ");
@@ -1796,7 +1798,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 5: case 5:
YY_RULE_SETUP YY_RULE_SETUP
#line 154 "toke.l" #line 156 "toke.l"
{ {
LEXTRACE("= "); LEXTRACE("= ");
LEXRETURN('='); LEXRETURN('=');
@@ -1804,7 +1806,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 6: case 6:
YY_RULE_SETUP YY_RULE_SETUP
#line 159 "toke.l" #line 161 "toke.l"
{ {
LEXTRACE("+= "); LEXTRACE("+= ");
LEXRETURN('+'); LEXRETURN('+');
@@ -1812,7 +1814,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 7: case 7:
YY_RULE_SETUP YY_RULE_SETUP
#line 164 "toke.l" #line 166 "toke.l"
{ {
LEXTRACE("-= "); LEXTRACE("-= ");
LEXRETURN('-'); LEXRETURN('-');
@@ -1820,7 +1822,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 8: case 8:
YY_RULE_SETUP YY_RULE_SETUP
#line 169 "toke.l" #line 171 "toke.l"
{ {
LEXTRACE("BEGINSTR "); LEXTRACE("BEGINSTR ");
yylval.string = NULL; yylval.string = NULL;
@@ -1830,7 +1832,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 9: case 9:
YY_RULE_SETUP YY_RULE_SETUP
#line 176 "toke.l" #line 178 "toke.l"
{ {
LEXTRACE("WORD(2) "); LEXTRACE("WORD(2) ");
if (!fill(yytext, yyleng)) if (!fill(yytext, yyleng))
@@ -1842,7 +1844,7 @@ YY_RULE_SETUP
case 10: case 10:
YY_RULE_SETUP YY_RULE_SETUP
#line 185 "toke.l" #line 187 "toke.l"
{ {
/* Line continuation char followed by newline. */ /* Line continuation char followed by newline. */
sudolineno++; sudolineno++;
@@ -1851,7 +1853,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 11: case 11:
YY_RULE_SETUP YY_RULE_SETUP
#line 191 "toke.l" #line 193 "toke.l"
{ {
LEXTRACE("ENDSTR "); LEXTRACE("ENDSTR ");
BEGIN prev_state; BEGIN prev_state;
@@ -1886,7 +1888,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 12: case 12:
YY_RULE_SETUP YY_RULE_SETUP
#line 223 "toke.l" #line 225 "toke.l"
{ {
LEXTRACE("BACKSLASH "); LEXTRACE("BACKSLASH ");
if (!append(yytext, yyleng)) if (!append(yytext, yyleng))
@@ -1895,7 +1897,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 13: case 13:
YY_RULE_SETUP YY_RULE_SETUP
#line 229 "toke.l" #line 231 "toke.l"
{ {
LEXTRACE("STRBODY "); LEXTRACE("STRBODY ");
if (!append(yytext, yyleng)) if (!append(yytext, yyleng))
@@ -1906,7 +1908,7 @@ YY_RULE_SETUP
case 14: case 14:
YY_RULE_SETUP YY_RULE_SETUP
#line 237 "toke.l" #line 239 "toke.l"
{ {
/* quoted fnmatch glob char, pass verbatim */ /* quoted fnmatch glob char, pass verbatim */
LEXTRACE("QUOTEDCHAR "); LEXTRACE("QUOTEDCHAR ");
@@ -1917,7 +1919,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 15: case 15:
YY_RULE_SETUP YY_RULE_SETUP
#line 245 "toke.l" #line 247 "toke.l"
{ {
/* quoted sudoers special char, strip backslash */ /* quoted sudoers special char, strip backslash */
LEXTRACE("QUOTEDCHAR "); LEXTRACE("QUOTEDCHAR ");
@@ -1928,7 +1930,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 16: case 16:
YY_RULE_SETUP YY_RULE_SETUP
#line 253 "toke.l" #line 255 "toke.l"
{ {
BEGIN INITIAL; BEGIN INITIAL;
yyless(0); yyless(0);
@@ -1937,7 +1939,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 17: case 17:
YY_RULE_SETUP YY_RULE_SETUP
#line 259 "toke.l" #line 261 "toke.l"
{ {
LEXTRACE("ARG "); LEXTRACE("ARG ");
if (!fill_args(yytext, yyleng, sawspace)) if (!fill_args(yytext, yyleng, sawspace))
@@ -1948,7 +1950,7 @@ YY_RULE_SETUP
case 18: case 18:
YY_RULE_SETUP YY_RULE_SETUP
#line 267 "toke.l" #line 269 "toke.l"
{ {
char *path; char *path;
@@ -1969,7 +1971,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 19: case 19:
YY_RULE_SETUP YY_RULE_SETUP
#line 285 "toke.l" #line 287 "toke.l"
{ {
char *path; char *path;
@@ -1993,7 +1995,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 20: case 20:
YY_RULE_SETUP YY_RULE_SETUP
#line 306 "toke.l" #line 308 "toke.l"
{ {
char deftype; char deftype;
int n; int n;
@@ -2036,7 +2038,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 21: case 21:
YY_RULE_SETUP YY_RULE_SETUP
#line 346 "toke.l" #line 348 "toke.l"
{ {
int n; int n;
@@ -2065,7 +2067,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 22: case 22:
YY_RULE_SETUP YY_RULE_SETUP
#line 372 "toke.l" #line 374 "toke.l"
{ {
/* cmnd does not require passwd for this user */ /* cmnd does not require passwd for this user */
LEXTRACE("NOPASSWD "); LEXTRACE("NOPASSWD ");
@@ -2074,7 +2076,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 23: case 23:
YY_RULE_SETUP YY_RULE_SETUP
#line 378 "toke.l" #line 380 "toke.l"
{ {
/* cmnd requires passwd for this user */ /* cmnd requires passwd for this user */
LEXTRACE("PASSWD "); LEXTRACE("PASSWD ");
@@ -2083,7 +2085,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 24: case 24:
YY_RULE_SETUP YY_RULE_SETUP
#line 384 "toke.l" #line 386 "toke.l"
{ {
LEXTRACE("NOEXEC "); LEXTRACE("NOEXEC ");
LEXRETURN(NOEXEC); LEXRETURN(NOEXEC);
@@ -2091,7 +2093,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 25: case 25:
YY_RULE_SETUP YY_RULE_SETUP
#line 389 "toke.l" #line 391 "toke.l"
{ {
LEXTRACE("EXEC "); LEXTRACE("EXEC ");
LEXRETURN(EXEC); LEXRETURN(EXEC);
@@ -2099,7 +2101,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 26: case 26:
YY_RULE_SETUP YY_RULE_SETUP
#line 394 "toke.l" #line 396 "toke.l"
{ {
LEXTRACE("SETENV "); LEXTRACE("SETENV ");
LEXRETURN(SETENV); LEXRETURN(SETENV);
@@ -2107,7 +2109,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 27: case 27:
YY_RULE_SETUP YY_RULE_SETUP
#line 399 "toke.l" #line 401 "toke.l"
{ {
LEXTRACE("NOSETENV "); LEXTRACE("NOSETENV ");
LEXRETURN(NOSETENV); LEXRETURN(NOSETENV);
@@ -2115,7 +2117,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 28: case 28:
YY_RULE_SETUP YY_RULE_SETUP
#line 404 "toke.l" #line 406 "toke.l"
{ {
LEXTRACE("LOG_OUTPUT "); LEXTRACE("LOG_OUTPUT ");
LEXRETURN(LOG_OUTPUT); LEXRETURN(LOG_OUTPUT);
@@ -2123,7 +2125,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 29: case 29:
YY_RULE_SETUP YY_RULE_SETUP
#line 409 "toke.l" #line 411 "toke.l"
{ {
LEXTRACE("NOLOG_OUTPUT "); LEXTRACE("NOLOG_OUTPUT ");
LEXRETURN(NOLOG_OUTPUT); LEXRETURN(NOLOG_OUTPUT);
@@ -2131,7 +2133,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 30: case 30:
YY_RULE_SETUP YY_RULE_SETUP
#line 414 "toke.l" #line 416 "toke.l"
{ {
LEXTRACE("LOG_INPUT "); LEXTRACE("LOG_INPUT ");
LEXRETURN(LOG_INPUT); LEXRETURN(LOG_INPUT);
@@ -2139,7 +2141,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 31: case 31:
YY_RULE_SETUP YY_RULE_SETUP
#line 419 "toke.l" #line 421 "toke.l"
{ {
LEXTRACE("NOLOG_INPUT "); LEXTRACE("NOLOG_INPUT ");
LEXRETURN(NOLOG_INPUT); LEXRETURN(NOLOG_INPUT);
@@ -2147,7 +2149,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 32: case 32:
YY_RULE_SETUP YY_RULE_SETUP
#line 424 "toke.l" #line 426 "toke.l"
{ {
/* empty group or netgroup */ /* empty group or netgroup */
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
@@ -2156,7 +2158,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 33: case 33:
YY_RULE_SETUP YY_RULE_SETUP
#line 430 "toke.l" #line 432 "toke.l"
{ {
/* netgroup */ /* netgroup */
if (!fill(yytext, yyleng)) if (!fill(yytext, yyleng))
@@ -2167,7 +2169,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 34: case 34:
YY_RULE_SETUP YY_RULE_SETUP
#line 438 "toke.l" #line 440 "toke.l"
{ {
/* group */ /* group */
if (!fill(yytext, yyleng)) if (!fill(yytext, yyleng))
@@ -2178,7 +2180,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 35: case 35:
YY_RULE_SETUP YY_RULE_SETUP
#line 446 "toke.l" #line 448 "toke.l"
{ {
if (!fill(yytext, yyleng)) if (!fill(yytext, yyleng))
yyterminate(); yyterminate();
@@ -2188,7 +2190,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 36: case 36:
YY_RULE_SETUP YY_RULE_SETUP
#line 453 "toke.l" #line 455 "toke.l"
{ {
if (!fill(yytext, yyleng)) if (!fill(yytext, yyleng))
yyterminate(); yyterminate();
@@ -2198,7 +2200,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 37: case 37:
YY_RULE_SETUP YY_RULE_SETUP
#line 460 "toke.l" #line 462 "toke.l"
{ {
if (!ipv6_valid(yytext)) { if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
@@ -2212,7 +2214,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 38: case 38:
YY_RULE_SETUP YY_RULE_SETUP
#line 471 "toke.l" #line 473 "toke.l"
{ {
if (!ipv6_valid(yytext)) { if (!ipv6_valid(yytext)) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
@@ -2226,7 +2228,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 39: case 39:
YY_RULE_SETUP YY_RULE_SETUP
#line 482 "toke.l" #line 484 "toke.l"
{ {
LEXTRACE("ALL "); LEXTRACE("ALL ");
LEXRETURN(ALL); LEXRETURN(ALL);
@@ -2235,7 +2237,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 40: case 40:
YY_RULE_SETUP YY_RULE_SETUP
#line 488 "toke.l" #line 490 "toke.l"
{ {
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX
LEXTRACE("ROLE "); LEXTRACE("ROLE ");
@@ -2247,7 +2249,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 41: case 41:
YY_RULE_SETUP YY_RULE_SETUP
#line 497 "toke.l" #line 499 "toke.l"
{ {
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX
LEXTRACE("TYPE "); LEXTRACE("TYPE ");
@@ -2259,7 +2261,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 42: case 42:
YY_RULE_SETUP YY_RULE_SETUP
#line 506 "toke.l" #line 508 "toke.l"
{ {
#ifndef HAVE_SELINUX #ifndef HAVE_SELINUX
got_alias: got_alias:
@@ -2272,7 +2274,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 43: case 43:
YY_RULE_SETUP YY_RULE_SETUP
#line 516 "toke.l" #line 518 "toke.l"
{ {
/* no command args allowed for Defaults!/path */ /* no command args allowed for Defaults!/path */
if (!fill_cmnd(yytext, yyleng)) if (!fill_cmnd(yytext, yyleng))
@@ -2283,7 +2285,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 44: case 44:
YY_RULE_SETUP YY_RULE_SETUP
#line 524 "toke.l" #line 526 "toke.l"
{ {
BEGIN GOTCMND; BEGIN GOTCMND;
LEXTRACE("COMMAND "); LEXTRACE("COMMAND ");
@@ -2293,7 +2295,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 45: case 45:
YY_RULE_SETUP YY_RULE_SETUP
#line 531 "toke.l" #line 533 "toke.l"
{ {
/* directories can't have args... */ /* directories can't have args... */
if (yytext[yyleng - 1] == '/') { if (yytext[yyleng - 1] == '/') {
@@ -2311,7 +2313,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 46: case 46:
YY_RULE_SETUP YY_RULE_SETUP
#line 546 "toke.l" #line 548 "toke.l"
{ {
LEXTRACE("BEGINSTR "); LEXTRACE("BEGINSTR ");
yylval.string = NULL; yylval.string = NULL;
@@ -2321,7 +2323,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 47: case 47:
YY_RULE_SETUP YY_RULE_SETUP
#line 553 "toke.l" #line 555 "toke.l"
{ {
/* a word */ /* a word */
if (!fill(yytext, yyleng)) if (!fill(yytext, yyleng))
@@ -2332,7 +2334,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 48: case 48:
YY_RULE_SETUP YY_RULE_SETUP
#line 561 "toke.l" #line 563 "toke.l"
{ {
LEXTRACE("( "); LEXTRACE("( ");
LEXRETURN('('); LEXRETURN('(');
@@ -2340,7 +2342,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 49: case 49:
YY_RULE_SETUP YY_RULE_SETUP
#line 566 "toke.l" #line 568 "toke.l"
{ {
LEXTRACE(") "); LEXTRACE(") ");
LEXRETURN(')'); LEXRETURN(')');
@@ -2348,7 +2350,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 50: case 50:
YY_RULE_SETUP YY_RULE_SETUP
#line 571 "toke.l" #line 573 "toke.l"
{ {
LEXTRACE(", "); LEXTRACE(", ");
LEXRETURN(','); LEXRETURN(',');
@@ -2356,7 +2358,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 51: case 51:
YY_RULE_SETUP YY_RULE_SETUP
#line 576 "toke.l" #line 578 "toke.l"
{ {
LEXTRACE("= "); LEXTRACE("= ");
LEXRETURN('='); LEXRETURN('=');
@@ -2364,7 +2366,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 52: case 52:
YY_RULE_SETUP YY_RULE_SETUP
#line 581 "toke.l" #line 583 "toke.l"
{ {
LEXTRACE(": "); LEXTRACE(": ");
LEXRETURN(':'); LEXRETURN(':');
@@ -2372,7 +2374,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 53: case 53:
YY_RULE_SETUP YY_RULE_SETUP
#line 586 "toke.l" #line 588 "toke.l"
{ {
if (yyleng & 1) { if (yyleng & 1) {
LEXTRACE("!"); LEXTRACE("!");
@@ -2382,7 +2384,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 54: case 54:
YY_RULE_SETUP YY_RULE_SETUP
#line 593 "toke.l" #line 595 "toke.l"
{ {
if (YY_START == INSTR) { if (YY_START == INSTR) {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
@@ -2397,14 +2399,14 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 55: case 55:
YY_RULE_SETUP YY_RULE_SETUP
#line 605 "toke.l" #line 607 "toke.l"
{ /* throw away space/tabs */ { /* throw away space/tabs */
sawspace = true; /* but remember for fill_args */ sawspace = true; /* but remember for fill_args */
} }
YY_BREAK YY_BREAK
case 56: case 56:
YY_RULE_SETUP YY_RULE_SETUP
#line 609 "toke.l" #line 611 "toke.l"
{ {
sawspace = true; /* remember for fill_args */ sawspace = true; /* remember for fill_args */
sudolineno++; sudolineno++;
@@ -2413,7 +2415,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 57: case 57:
YY_RULE_SETUP YY_RULE_SETUP
#line 615 "toke.l" #line 617 "toke.l"
{ {
BEGIN INITIAL; BEGIN INITIAL;
sudolineno++; sudolineno++;
@@ -2424,7 +2426,7 @@ YY_RULE_SETUP
YY_BREAK YY_BREAK
case 58: case 58:
YY_RULE_SETUP YY_RULE_SETUP
#line 623 "toke.l" #line 625 "toke.l"
{ {
LEXTRACE("ERROR "); LEXTRACE("ERROR ");
LEXRETURN(ERROR); LEXRETURN(ERROR);
@@ -2436,7 +2438,7 @@ case YY_STATE_EOF(GOTCMND):
case YY_STATE_EOF(STARTDEFS): case YY_STATE_EOF(STARTDEFS):
case YY_STATE_EOF(INDEFS): case YY_STATE_EOF(INDEFS):
case YY_STATE_EOF(INSTR): case YY_STATE_EOF(INSTR):
#line 628 "toke.l" #line 630 "toke.l"
{ {
if (YY_START != INITIAL) { if (YY_START != INITIAL) {
BEGIN INITIAL; BEGIN INITIAL;
@@ -2449,10 +2451,10 @@ case YY_STATE_EOF(INSTR):
YY_BREAK YY_BREAK
case 59: case 59:
YY_RULE_SETUP YY_RULE_SETUP
#line 638 "toke.l" #line 640 "toke.l"
ECHO; ECHO;
YY_BREAK YY_BREAK
#line 2455 "lex.yy.c" #line 2457 "lex.yy.c"
case YY_END_OF_BUFFER: case YY_END_OF_BUFFER:
{ {
@@ -3343,7 +3345,7 @@ int main()
return 0; return 0;
} }
#endif #endif
#line 638 "toke.l" #line 640 "toke.l"
struct path_list { struct path_list {
char *path; char *path;

View File

@@ -102,6 +102,8 @@ int (*trace_print)(const char *msg) = sudoers_trace_print;
return (n); \ return (n); \
} while (0) } while (0)
#define ECHO ignore_result(fwrite(yytext, yyleng, 1, yyout))
#define push_include(_p) (_push_include((_p), false)) #define push_include(_p) (_push_include((_p), false))
#define push_includedir(_p) (_push_include((_p), true)) #define push_includedir(_p) (_push_include((_p), true))
%} %}

View File

@@ -563,9 +563,9 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
(void) unlink(sp->tpath); (void) unlink(sp->tpath);
if (!oldperms && fstat(sp->fd, &sb) != -1) { if (!oldperms && fstat(sp->fd, &sb) != -1) {
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID)
(void) chown(sp->path, SUDOERS_UID, SUDOERS_GID); ignore_result(chown(sp->path, SUDOERS_UID, SUDOERS_GID));
if ((sb.st_mode & 0777) != SUDOERS_MODE) if ((sb.st_mode & 0777) != SUDOERS_MODE)
(void) chmod(sp->path, SUDOERS_MODE); ignore_result(chmod(sp->path, SUDOERS_MODE));
} }
rval = true; rval = true;
goto done; goto done;
@@ -1279,11 +1279,10 @@ quit(int signo)
#define emsg " exiting due to signal: " #define emsg " exiting due to signal: "
myname = getprogname(); myname = getprogname();
signame = strsignal(signo); signame = strsignal(signo);
if (write(STDERR_FILENO, myname, strlen(myname)) == -1 || ignore_result(write(STDERR_FILENO, myname, strlen(myname)));
write(STDERR_FILENO, emsg, sizeof(emsg) - 1) == -1 || ignore_result(write(STDERR_FILENO, emsg, sizeof(emsg) - 1));
write(STDERR_FILENO, signame, strlen(signame)) == -1 || ignore_result(write(STDERR_FILENO, signame, strlen(signame)));
write(STDERR_FILENO, "\n", 1) == -1) ignore_result(write(STDERR_FILENO, "\n", 1));
/* shut up glibc */;
_exit(signo); _exit(signo);
} }

View File

@@ -67,6 +67,8 @@ rpl_getenv(const char *name)
return val; return val;
} }
typedef char * (*sudo_fn_getenv_t)(const char *);
char * char *
getenv(const char *name) getenv(const char *name)
{ {
@@ -79,9 +81,9 @@ getenv(const char *name)
return NULL; return NULL;
default: { default: {
#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT) #if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
char * (*fn)(const char *); sudo_fn_getenv_t fn;
fn = dlsym(RTLD_NEXT, "getenv"); fn = (sudo_fn_getenv_t)dlsym(RTLD_NEXT, "getenv");
if (fn != NULL) if (fn != NULL)
return fn(name); return fn(name);
#endif /* HAVE_DLOPEN && RTLD_NEXT */ #endif /* HAVE_DLOPEN && RTLD_NEXT */
@@ -132,6 +134,8 @@ rpl_putenv(PUTENV_CONST char *string)
return 0; return 0;
} }
typedef int (*sudo_fn_putenv_t)(PUTENV_CONST char *);
int int
putenv(PUTENV_CONST char *string) putenv(PUTENV_CONST char *string)
{ {
@@ -142,9 +146,9 @@ putenv(PUTENV_CONST char *string)
return -1; return -1;
default: { default: {
#if defined(HAVE_DLOPEN) && defined(RTLD_NEXT) #if defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
int (*fn)(PUTENV_CONST char *); sudo_fn_putenv_t fn;
fn = dlsym(RTLD_NEXT, "putenv"); fn = (sudo_fn_putenv_t)dlsym(RTLD_NEXT, "putenv");
if (fn != NULL) if (fn != NULL)
return fn(string); return fn(string);
#endif /* HAVE_DLOPEN && RTLD_NEXT */ #endif /* HAVE_DLOPEN && RTLD_NEXT */
@@ -195,6 +199,8 @@ rpl_setenv(const char *var, const char *val, int overwrite)
return rpl_putenv(envstr); return rpl_putenv(envstr);
} }
typedef int (*sudo_fn_setenv_t)(const char *, const char *, int);
int int
setenv(const char *var, const char *val, int overwrite) setenv(const char *var, const char *val, int overwrite)
{ {
@@ -205,9 +211,9 @@ setenv(const char *var, const char *val, int overwrite)
return -1; return -1;
default: { default: {
#if defined(HAVE_SETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT) #if defined(HAVE_SETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
int (*fn)(const char *, const char *, int); sudo_fn_setenv_t fn;
fn = dlsym(RTLD_NEXT, "setenv"); fn = (sudo_fn_setenv_t)dlsym(RTLD_NEXT, "setenv");
if (fn != NULL) if (fn != NULL)
return fn(var, val, overwrite); return fn(var, val, overwrite);
#endif /* HAVE_SETENV && HAVE_DLOPEN && RTLD_NEXT */ #endif /* HAVE_SETENV && HAVE_DLOPEN && RTLD_NEXT */
@@ -252,6 +258,12 @@ rpl_unsetenv(const char *var)
#endif #endif
} }
#ifdef UNSETENV_VOID
typedef void (*sudo_fn_unsetenv_t)(const char *);
#else
typedef int (*sudo_fn_unsetenv_t)(const char *);
#endif
#ifdef UNSETENV_VOID #ifdef UNSETENV_VOID
void void
unsetenv(const char *var) unsetenv(const char *var)
@@ -263,9 +275,9 @@ unsetenv(const char *var)
return -1; return -1;
default: { default: {
#if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT) #if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
void (*fn)(const char *); sudo_fn_unsetenv_t fn;
fn = dlsym(RTLD_NEXT, "unsetenv"); fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
if (fn != NULL) if (fn != NULL)
fn(var); fn(var);
else else
@@ -285,9 +297,9 @@ unsetenv(const char *var)
return -1; return -1;
default: { default: {
#if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT) #if defined(HAVE_UNSETENV) && defined(HAVE_DLOPEN) && defined(RTLD_NEXT)
int (*fn)(const char *); sudo_fn_unsetenv_t fn;
fn = dlsym(RTLD_NEXT, "unsetenv"); fn = (sudo_fn_unsetenv_t)dlsym(RTLD_NEXT, "unsetenv");
if (fn != NULL) if (fn != NULL)
return fn(var); return fn(var);
#endif /* HAVE_UNSETENV && HAVE_DLOPEN && RTLD_NEXT */ #endif /* HAVE_UNSETENV && HAVE_DLOPEN && RTLD_NEXT */

View File

@@ -604,8 +604,7 @@ handler(int s)
* The pipe is non-blocking, if we overflow the kernel's pipe * The pipe is non-blocking, if we overflow the kernel's pipe
* buffer we drop the signal. This is not a problem in practice. * buffer we drop the signal. This is not a problem in practice.
*/ */
if (write(signal_pipe[1], &signo, sizeof(signo)) == -1) ignore_result(write(signal_pipe[1], &signo, sizeof(signo)));
/* shut up glibc */;
} }
#ifdef SA_SIGINFO #ifdef SA_SIGINFO
@@ -626,8 +625,7 @@ handler_nofwd(int s, siginfo_t *info, void *context)
* The pipe is non-blocking, if we overflow the kernel's pipe * The pipe is non-blocking, if we overflow the kernel's pipe
* buffer we drop the signal. This is not a problem in practice. * buffer we drop the signal. This is not a problem in practice.
*/ */
if (write(signal_pipe[1], &signo, sizeof(signo)) == -1) ignore_result(write(signal_pipe[1], &signo, sizeof(signo)));
/* shut up glibc */;
} }
} }
#endif /* SA_SIGINFO */ #endif /* SA_SIGINFO */

View File

@@ -695,11 +695,9 @@ pty_close(struct command_status *cstat)
io_fds[SFD_USERTTY] : STDOUT_FILENO; io_fds[SFD_USERTTY] : STDOUT_FILENO;
if (write(n, reason, strlen(reason)) != -1) { if (write(n, reason, strlen(reason)) != -1) {
if (WCOREDUMP(cstat->val)) { if (WCOREDUMP(cstat->val)) {
if (write(n, " (core dumped)", 14) == -1) ignore_result(write(n, " (core dumped)", 14));
/* shut up glibc */;
} }
if (write(n, "\n", 1) == -1) ignore_result(write(n, "\n", 1));
/* shut up glibc */;
} }
} }
} }
@@ -961,8 +959,7 @@ exec_monitor(struct command_details *details, int backchannel)
exec_pty(details, &errpipe[1]); exec_pty(details, &errpipe[1]);
cstat.type = CMD_ERRNO; cstat.type = CMD_ERRNO;
cstat.val = errno; cstat.val = errno;
if (write(errpipe[1], &cstat, sizeof(cstat)) == -1) ignore_result(write(errpipe[1], &cstat, sizeof(cstat)));
/* shut up glibc */;
_exit(1); _exit(1);
} }
close(errpipe[1]); close(errpipe[1]);

View File

@@ -298,8 +298,7 @@ getln(int fd, char *buf, size_t bufsiz, int feedback)
} }
continue; continue;
} }
if (write(fd, "*", 1) == -1) ignore_result(write(fd, "*", 1));
/* shut up glibc */;
} }
*cp++ = c; *cp++ = c;
} }