mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 06:15:37 +00:00
Escape control characters in log messages and "sudoreplay -l" output.
The log message contains user-controlled strings that could include things like terminal control characters. Space characters in the command path are now also escaped. Command line arguments that contain spaces are surrounded with single quotes and any literal single quote or backslash characters are escaped with a backslash. This makes it possible to distinguish multiple command line arguments from a single argument that contains spaces. Issue found by Matthieu Barjole and Victor Cutillas of Synacktiv (https://synacktiv.com).
This commit is contained in:
@@ -36,9 +36,15 @@ struct sudo_lbuf {
|
||||
|
||||
typedef int (*sudo_lbuf_output_t)(const char *);
|
||||
|
||||
/* Flags for sudo_lbuf_append_esc() */
|
||||
#define LBUF_ESC_CNTRL 0x01
|
||||
#define LBUF_ESC_BLANK 0x02
|
||||
#define LBUF_ESC_QUOTE 0x04
|
||||
|
||||
sudo_dso_public void sudo_lbuf_init_v1(struct sudo_lbuf *lbuf, sudo_lbuf_output_t output, int indent, const char *continuation, int cols);
|
||||
sudo_dso_public void sudo_lbuf_destroy_v1(struct sudo_lbuf *lbuf);
|
||||
sudo_dso_public bool sudo_lbuf_append_v1(struct sudo_lbuf *lbuf, const char *fmt, ...) sudo_printflike(2, 3);
|
||||
sudo_dso_public bool sudo_lbuf_append_esc_v1(struct sudo_lbuf *lbuf, int flags, const char *fmt, ...) sudo_printflike(3, 4);
|
||||
sudo_dso_public bool sudo_lbuf_append_quoted_v1(struct sudo_lbuf *lbuf, const char *set, const char *fmt, ...) sudo_printflike(3, 4);
|
||||
sudo_dso_public void sudo_lbuf_print_v1(struct sudo_lbuf *lbuf);
|
||||
sudo_dso_public bool sudo_lbuf_error_v1(struct sudo_lbuf *lbuf);
|
||||
@@ -47,6 +53,7 @@ sudo_dso_public void sudo_lbuf_clearerr_v1(struct sudo_lbuf *lbuf);
|
||||
#define sudo_lbuf_init(_a, _b, _c, _d, _e) sudo_lbuf_init_v1((_a), (_b), (_c), (_d), (_e))
|
||||
#define sudo_lbuf_destroy(_a) sudo_lbuf_destroy_v1((_a))
|
||||
#define sudo_lbuf_append sudo_lbuf_append_v1
|
||||
#define sudo_lbuf_append_esc sudo_lbuf_append_esc_v1
|
||||
#define sudo_lbuf_append_quoted sudo_lbuf_append_quoted_v1
|
||||
#define sudo_lbuf_print(_a) sudo_lbuf_print_v1((_a))
|
||||
#define sudo_lbuf_error(_a) sudo_lbuf_error_v1((_a))
|
||||
|
Reference in New Issue
Block a user