From: Werner Koch Date: Fri, 20 Jun 2008 09:53:54 +0000 (+0000) Subject: Fix parsing of long lines. X-Git-Tag: gpgme-1.2.0@1385~66 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4fbd8dc73ea11acd7c599f39e28325905ab55e28;p=gpgme.git Fix parsing of long lines. --- diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index f527ba9..8c35959 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2008-06-20 Werner Koch + + * engine-gpgconf.c (gpgconf_read): Change ARGV initialization for + compatibility with old compilers. Fix amount of memmove. Fix + CR removal. + 2008-06-19 Werner Koch * gpgme.h (GPGME_CONF_PATHNAME): Replace by GPGME_CONF_FILENAME, diff --git a/trunk/gpgme/engine-gpgconf.c b/trunk/gpgme/engine-gpgconf.c index c894dea..6a9cf2b 100644 --- a/trunk/gpgme/engine-gpgconf.c +++ b/trunk/gpgme/engine-gpgconf.c @@ -199,7 +199,7 @@ gpgconf_read (void *engine, char *arg1, char *arg2, #define LINELENGTH 1024 char linebuf[LINELENGTH] = ""; int linelen = 0; - char *argv[] = { NULL /* file_name */, arg1, arg2, 0 }; + char *argv[4] = { NULL /* file_name */, NULL, NULL, NULL }; int rp[2]; struct spawn_fd_item_s pfd[] = { {0, -1}, {-1, -1} }; struct spawn_fd_item_s cfd[] = { {-1, 1 /* STDOUT_FILENO */}, {-1, -1} }; @@ -207,6 +207,10 @@ gpgconf_read (void *engine, char *arg1, char *arg2, int nread; char *mark = NULL; + argv[1] = arg1; + argv[2] = arg2; + + /* FIXME: Deal with engine->home_dir. */ /* _gpgme_engine_new guarantees that this is not NULL. */ @@ -243,20 +247,21 @@ gpgconf_read (void *engine, char *arg1, char *arg2, { lastmark = mark; if (mark > line && mark[-1] == '\r') - mark--; - *mark = '\0'; + mark[-1] = '\0'; + else + mark[0] = '\0'; /* Got a full line. Due to the CR removal code (which occurs only on Windows) we might be one-off and thus would see empty lines. Don't pass them to the callback. */ - err = *line? (*cb) (hook, line) : NULL; + err = *line? (*cb) (hook, line) : 0; if (err) goto leave; } nused = lastmark? (lastmark + 1 - linebuf) : 0; - memmove (linebuf, linebuf + nused, nused); + memmove (linebuf, linebuf + nused, linelen - nused); linelen -= nused; } }