mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 09:57:41 +00:00
Clear sudoers_errstr after it is used.
This way we avoid printing the same error message more than once if there are multiple ERROR tokens returned from the lexer.
This commit is contained in:
parent
3c1ce4bf72
commit
c8bf591042
@ -3344,10 +3344,7 @@ sudoerserrorf(const char *fmt, ...)
|
|||||||
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (sudoerschar == ERROR) {
|
if (strcmp(fmt, "%s") == 0) {
|
||||||
/* Use error string from lexer. */
|
|
||||||
s = _(sudoers_errstr);
|
|
||||||
} else if (strcmp(fmt, "%s") == 0) {
|
|
||||||
/* Optimize common case, a single string. */
|
/* Optimize common case, a single string. */
|
||||||
s = _(va_arg(ap, char *));
|
s = _(va_arg(ap, char *));
|
||||||
} else {
|
} else {
|
||||||
@ -3389,6 +3386,12 @@ sudoerserrorf(const char *fmt, ...)
|
|||||||
void
|
void
|
||||||
sudoerserror(const char *s)
|
sudoerserror(const char *s)
|
||||||
{
|
{
|
||||||
|
if (sudoerschar == ERROR) {
|
||||||
|
/* Use error string from lexer. */
|
||||||
|
s = sudoers_errstr;
|
||||||
|
sudoers_errstr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// -V:sudoerserror:575, 618
|
// -V:sudoerserror:575, 618
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
sudoerserrorf(NULL);
|
sudoerserrorf(NULL);
|
||||||
|
@ -1188,10 +1188,7 @@ sudoerserrorf(const char *fmt, ...)
|
|||||||
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
if (sudoerschar == ERROR) {
|
if (strcmp(fmt, "%s") == 0) {
|
||||||
/* Use error string from lexer. */
|
|
||||||
s = _(sudoers_errstr);
|
|
||||||
} else if (strcmp(fmt, "%s") == 0) {
|
|
||||||
/* Optimize common case, a single string. */
|
/* Optimize common case, a single string. */
|
||||||
s = _(va_arg(ap, char *));
|
s = _(va_arg(ap, char *));
|
||||||
} else {
|
} else {
|
||||||
@ -1233,6 +1230,12 @@ sudoerserrorf(const char *fmt, ...)
|
|||||||
void
|
void
|
||||||
sudoerserror(const char *s)
|
sudoerserror(const char *s)
|
||||||
{
|
{
|
||||||
|
if (sudoerschar == ERROR) {
|
||||||
|
/* Use error string from lexer. */
|
||||||
|
s = sudoers_errstr;
|
||||||
|
sudoers_errstr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// -V:sudoerserror:575, 618
|
// -V:sudoerserror:575, 618
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
sudoerserrorf(NULL);
|
sudoerserrorf(NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user