From 13acd78a39750e3990684a5bb0951fe0db83fc5a Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 19 Jan 2011 18:05:15 +0100 Subject: [PATCH] Fixed a CR/LF problem on Windows --- agent/ChangeLog | 4 ++++ agent/trustlist.c | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/agent/ChangeLog b/agent/ChangeLog index ce1fdccd8..542695bea 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,7 @@ +2011-01-19 Werner Koch + + * trustlist.c (read_one_trustfile): Also chop an CR. + 2010-12-02 Werner Koch * gpg-agent.c (CHECK_OWN_SOCKET_INTERVAL) [W32CE]: Set to 60 diff --git a/agent/trustlist.c b/agent/trustlist.c index 791df9682..d56598245 100644 --- a/agent/trustlist.c +++ b/agent/trustlist.c @@ -139,8 +139,9 @@ read_one_trustfile (const char *fname, int allow_include, while (es_fgets (line, DIM(line)-1, fp)) { lnr++; - - if (!*line || line[strlen(line)-1] != '\n') + + n = strlen (line); + if (!n || line[n-1] != '\n') { /* Eat until end of line. */ while ( (c=es_getc (fp)) != EOF && c != '\n') @@ -151,7 +152,9 @@ read_one_trustfile (const char *fname, int allow_include, fname, lnr, gpg_strerror (err)); continue; } - line[strlen(line)-1] = 0; /* Chop the LF. */ + line[--n] = 0; /* Chop the LF. */ + if (n && line[n-1] == '\r') + line[--n] = 0; /* Chop an optional CR. */ /* Allow for empty lines and spaces */ for (p=line; spacep (p); p++)