From 4d4e3b28973f6e5d3ab42833c922e79ed6148f0f Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 2 Sep 2021 16:28:16 +0200 Subject: [PATCH] Tolerate carriage return in config files If the file has been transferred from a Windows system then it might have \r\n line endings instead of \n. Make sure this doesn't leak in to the parameter values. --- vncviewer/parameters.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vncviewer/parameters.cxx b/vncviewer/parameters.cxx index a4e18363..8db714ae 100644 --- a/vncviewer/parameters.cxx +++ b/vncviewer/parameters.cxx @@ -776,6 +776,10 @@ char* loadViewerParameters(const char *filename) { line[len-1] = '\0'; len--; } + if (line[len-1] == '\r') { + line[len-1] = '\0'; + len--; + } // Find the parameter value char *value = strchr(line, '='); -- 2.39.5