Skip to content
This repository
Browse code

Merge pull request #192 from attilamolnar/insp12+chopfix

[1.2] Fix last character being chopped off in motd/rules
  • Loading branch information...
commit 5749279c7ec8447bbf6c1a2ee1886a9826e400c7 2 parents 622bf2b + 6ab2ef5
authored June 12, 2012

Showing 1 changed file with 8 additions and 1 deletion. Show diff stats Hide diff stats

  1. 9  src/configreader.cpp
9  src/configreader.cpp
@@ -1960,7 +1960,14 @@ bool ServerConfig::ReadFile(file_cache &F, const char* fname)
1960 1960
 		while (!feof(file))
1961 1961
 		{
1962 1962
 			if (fgets(linebuf, sizeof(linebuf), file))
1963  
-				linebuf[strlen(linebuf)-1] = 0;
  1963
+			{
  1964
+				// Cut off the ending newline, if any
  1965
+				size_t len = strlen(linebuf)-1;
  1966
+				if (linebuf[len] == '\n')
  1967
+				{
  1968
+					linebuf[len] = 0;
  1969
+				}
  1970
+			}
1964 1971
 			else
1965 1972
 				*linebuf = 0;
1966 1973
 

0 notes on commit 5749279

Please sign in to comment.
Something went wrong with that request. Please try again.