mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 05:15:06 -05:00
conf: detect truncated lines
If the buffer filled by fgets() is full, indicating it might not contain the whole line, abort with a fatal message.
This commit is contained in:
6
conf.c
6
conf.c
@@ -433,7 +433,7 @@ void
|
|||||||
CNF_ReadFile(const char *filename)
|
CNF_ReadFile(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char line[MAX_LINE_LENGTH];
|
char line[MAX_LINE_LENGTH + 1];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
include_level++;
|
include_level++;
|
||||||
@@ -463,6 +463,10 @@ CNF_ParseLine(const char *filename, int number, char *line)
|
|||||||
processed_file = filename;
|
processed_file = filename;
|
||||||
line_number = number;
|
line_number = number;
|
||||||
|
|
||||||
|
/* Detect truncated line */
|
||||||
|
if (strlen(line) >= MAX_LINE_LENGTH)
|
||||||
|
other_parse_error("String too long");
|
||||||
|
|
||||||
/* Remove extra white-space and comments */
|
/* Remove extra white-space and comments */
|
||||||
CPS_NormalizeLine(line);
|
CPS_NormalizeLine(line);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user