Fix bad long line detection logic in config file parser
diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx
index 712a257..7a868c7 100644
--- a/vncviewer/parameters.cxx
+++ b/vncviewer/parameters.cxx
@@ -580,15 +580,16 @@
// Read the next line
lineNr++;
if (!fgets(line, sizeof(line), f)) {
- if (line[sizeof(line) -1] != '\0')
- throw Exception(_("Failed to read line %d in file %s: %s"),
- lineNr, filepath, _("Line too long"));
if (feof(f))
break;
throw Exception(_("Failed to read line %d in file %s: %s"),
lineNr, filepath, strerror(errno));
}
+
+ if (strlen(line) == (sizeof(line) - 1))
+ throw Exception(_("Failed to read line %d in file %s: %s"),
+ lineNr, filepath, _("Line too long"));
// Make sure that the first line of the file has the file identifier string
if(lineNr == 1) {