From: brain Date: Sun, 29 May 2005 19:59:47 +0000 (+0000) Subject: Fixed to allow any form of linefeed X-Git-Tag: v2.0.23~10138 X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=40b9d63a3c7264e715a37332515680ae3c2f844d;p=user%2Fhenk%2Fcode%2Finspircd.git Fixed to allow any form of linefeed git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1559 e03df62e-2008-0410-955e-edbf42e46eb7 --- 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))) {