Don't recurse infinitely until we blow the stack when the debug

file can't be opened in the front-end.  The conversation-type debug
mode will be removed in the future.
This commit is contained in:
Todd C. Miller
2014-08-18 16:35:58 -06:00
parent dbe0b213da
commit 2246b1827f
2 changed files with 8 additions and 2 deletions

View File

@@ -122,6 +122,9 @@ static char sudo_debug_pidstr[(((sizeof(int) * 8) + 2) / 3) + 3];
static size_t sudo_debug_pidlen; static size_t sudo_debug_pidlen;
static const int num_subsystems = NUM_SUBSYSTEMS; static const int num_subsystems = NUM_SUBSYSTEMS;
/* Exposed for sudo_printf.c */
void sudo_debug_write_file(const char *func, const char *file, int line, const char *str, int len, int errno_val);
/* /*
* Parse settings string from sudo.conf and open debugfile. * Parse settings string from sudo.conf and open debugfile.
* Returns 1 on success, 0 if cannot open debugfile. * Returns 1 on success, 0 if cannot open debugfile.
@@ -331,7 +334,7 @@ sudo_debug_write_conv(const char *func, const char *file, int lineno,
} }
} }
static void void
sudo_debug_write_file(const char *func, const char *file, int lineno, sudo_debug_write_file(const char *func, const char *file, int lineno,
const char *str, int len, int errnum) const char *str, int len, int errnum)
{ {

View File

@@ -33,6 +33,9 @@
#include "sudo_plugin.h" #include "sudo_plugin.h"
#include "sudo_debug.h" #include "sudo_debug.h"
/* Not exported outside libsudo_util */
void sudo_debug_write_file(const char *func, const char *file, int line, const char *str, int len, int errno_val);
__dso_public int __dso_public int
_sudo_printf(int msg_type, const char *fmt, ...) _sudo_printf(int msg_type, const char *fmt, ...)
{ {
@@ -57,7 +60,7 @@ _sudo_printf(int msg_type, const char *fmt, ...)
len = vasprintf(&buf, fmt, ap); len = vasprintf(&buf, fmt, ap);
va_end(ap); va_end(ap);
if (len != -1) if (len != -1)
sudo_debug_write(buf, len, 0); sudo_debug_write_file(NULL, NULL, 0, buf, len, 0);
break; break;
default: default:
errno = EINVAL; errno = EINVAL;