Skip to content

Commit 7aa006e

Browse files
committed
Fixed #8485: Segfault on incorrect databases.conf starting with subconfig
1 parent 8aac2fd commit 7aa006e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/common/config/config_file.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,14 +669,10 @@ void ConfigFile::parse(Stream* stream)
669669
case LINE_END_SUB:
670670
case LINE_BAD:
671671
badLine(streamName, inputLine);
672-
return;
673672

674673
case LINE_REGULAR:
675674
if (current.name.isEmpty())
676-
{
677675
badLine(streamName, inputLine);
678-
return;
679-
}
680676

681677
previous = &parameters[parameters.add(current)];
682678
break;
@@ -692,6 +688,9 @@ void ConfigFile::parse(Stream* stream)
692688
previous = &parameters[n];
693689
}
694690

691+
if (!previous)
692+
badLine(streamName, "master parameter is missing before subconfig start '{'");
693+
695694
{ // subconf scope
696695
SubStream subStream(stream->getFileName());
697696
int level = 1;
@@ -725,7 +724,6 @@ void ConfigFile::parse(Stream* stream)
725724

726725
case LINE_BAD:
727726
badLine(streamName, inputLine);
728-
return;
729727

730728
default:
731729
subStream.putLine(inputLine, line);
@@ -735,7 +733,7 @@ void ConfigFile::parse(Stream* stream)
735733
}
736734

737735
if (level > 0)
738-
badLine(streamName, "< missed closing bracket '}' >");
736+
badLine(streamName, "missed closing bracket '}'");
739737

740738
previous->sub = FB_NEW_POOL(getPool())
741739
ConfigFile(getPool(), &subStream, flags);

src/common/config/config_file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class ConfigFile : public Firebird::AutoStorage, public Firebird::RefCounted
141141
void parse(Stream* stream);
142142
LineType parseLine(const char* fileName, const String& input, Parameter& par);
143143
bool translate(const char* fileName, const String& from, String& to) const;
144-
void badLine(const char* fileName, const String& line);
144+
[[noreturn]] void badLine(const char* fileName, const String& line);
145145
void include(const char* currentFileName, const Firebird::PathName& path);
146146
bool wildCards(const char* currentFileName, const Firebird::PathName& pathPrefix, FilesArray& components);
147147
bool substituteStandardDir(const String& from, String& to) const;

0 commit comments

Comments
 (0)