summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-29 19:59:47 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-05-29 19:59:47 +0000
commit40b9d63a3c7264e715a37332515680ae3c2f844d (patch)
tree8f06aa88715d36954416934431386d9dc0a4a007
parent0501b8c1d966ca8becea0e517e140a58e5fd83a1 (diff)
Fixed to allow any form of linefeed
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1559 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/inspircd_io.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/inspircd_io.cpp b/src/inspircd_io.cpp
index c3f725c14..96a751d65 100644
--- a/src/inspircd_io.cpp
+++ b/src/inspircd_io.cpp
@@ -286,6 +286,20 @@ std::string ConfProcess(char* buffer, long linenumber, std::stringstream* errors
return parsedata;
}
+int fgets_safe(char* buffer, size_t maxsize, FILE* &file)
+{
+ char c_read = '\0';
+ unsigned int bufptr = 0;
+ while ((!feof(file)) && (c_read != '\n') && (c_read != '\r') && (bufptr < maxsize))
+ {
+ c_read = fgetc(file);
+ if ((c_read != '\n') && (c_read != '\r'))
+ buffer[bufptr++] = c_read;
+ }
+ buffer[bufptr] = '\0';
+ return bufptr;
+}
+
bool LoadConf(const char* filename, std::stringstream *target, std::stringstream* errorstream)
{
target->str("");
@@ -315,7 +329,7 @@ bool LoadConf(const char* filename, std::stringstream *target, std::stringstream
{
while (!feof(conf))
{
- if (fgets(buffer, MAXBUF, conf))
+ if (fgets_safe(buffer, MAXBUF, conf))
{
if ((!feof(conf)) && (buffer) && (strlen(buffer)))
{