]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fixed to allow any form of linefeed
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 29 May 2005 19:59:47 +0000 (19:59 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 29 May 2005 19:59:47 +0000 (19:59 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1559 e03df62e-2008-0410-955e-edbf42e46eb7

src/inspircd_io.cpp

index c3f725c14a1190a3c6e94aa9355f2bdc7f8b5205..96a751d6512afb2b000942b85e56325a31ec3dad 100644 (file)
@@ -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)))
                                {