parseServiceFile.patch

text/x-patch

Filename: parseServiceFile.patch
Type: text/x-patch
Part: 0
Message: Re: BUG #15827: Unable to connect on Windows using pg_services.conf using Python psycopg2

Patch

Format: unified
File+
src/interfaces/libpq/fe-connect.c 4 0
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index c800d7921e..e11cdb90d0 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -5036,6 +5036,10 @@ parseServiceFile(const char *serviceFile,
 		if (strlen(line) && line[strlen(line) - 1] == '\n')
 			line[strlen(line) - 1] = 0;
 
+		/* ignore CR at end of line */
+		if (strlen(line) && line[strlen(line) - 1] == '\r')
+			line[strlen(line) - 1] = 0;
+
 		/* ignore leading blanks */
 		while (*line && isspace((unsigned char) line[0]))
 			line++;