Add flag to sudo_parseln() to disable line continuation support.
This commit is contained in:
@@ -140,6 +140,7 @@
|
||||
|
||||
/* sudo_parseln() flags */
|
||||
#define PARSELN_COMM_BOL 1 /* comments only at begining of line */
|
||||
#define PARSELN_CONT_IGN 2 /* ignore line continuation char */
|
||||
|
||||
/*
|
||||
* Macros to quiet gcc's warn_unused_result attribute.
|
||||
|
@@ -50,10 +50,11 @@ sudo_parseln_v2(char **bufp, size_t *bufsizep, unsigned int *lineno, FILE *fp, i
|
||||
size_t linesize = 0, total = 0;
|
||||
ssize_t len;
|
||||
char *cp, *line = NULL;
|
||||
bool continued;
|
||||
bool continued, comment;
|
||||
debug_decl(sudo_parseln, SUDO_DEBUG_UTIL)
|
||||
|
||||
do {
|
||||
comment = false;
|
||||
continued = false;
|
||||
len = getline(&line, &linesize, fp);
|
||||
if (len == -1)
|
||||
@@ -70,11 +71,15 @@ sudo_parseln_v2(char **bufp, size_t *bufsizep, unsigned int *lineno, FILE *fp, i
|
||||
if (cp == line || !ISSET(flags, PARSELN_COMM_BOL)) {
|
||||
*cp = '\0';
|
||||
len = (ssize_t)(cp - line);
|
||||
comment = true;
|
||||
}
|
||||
} else if (len > 0 && line[len - 1] == '\\' && (len == 1 || line[len - 2] != '\\')) {
|
||||
}
|
||||
if (!comment && !ISSET(flags, PARSELN_CONT_IGN)) {
|
||||
if (len > 0 && line[len - 1] == '\\' && (len == 1 || line[len - 2] != '\\')) {
|
||||
line[--len] = '\0';
|
||||
continued = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Trim leading and trailing whitespace */
|
||||
if (!continued) {
|
||||
|
Reference in New Issue
Block a user