From: Werner Koch Date: Mon, 28 Apr 2008 18:42:56 +0000 (+0000) Subject: Fixed a bug reading from gpgconf. X-Git-Tag: gpgme-1.2.0@1385~74 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bbd21d3a1ac260cd2cbc8816a8b2792fde97e44f;p=gpgme.git Fixed a bug reading from gpgconf. --- diff --git a/trunk/ChangeLog b/trunk/ChangeLog index f6a0f2d..64316bc 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,3 +1,7 @@ +2008-04-01 Werner Koch + + * configure.ac (AC_INIT): Fix quoting. + 2008-01-30 Marcus Brinkmann * configure.ac: Bump required version of automake up to 1.10. diff --git a/trunk/configure.ac b/trunk/configure.ac index 5016b1c..e824b47 100644 --- a/trunk/configure.ac +++ b/trunk/configure.ac @@ -36,7 +36,8 @@ m4_define(my_issvn, [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) -AC_INIT([gpgme], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]), +AC_INIT([gpgme], + [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])], [bug-gpgme@gnupg.org]) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 219d482..e5b441b 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,8 @@ +2008-04-28 Werner Koch + + * engine-gpgconf.c (gpgconf_read): Fixed segv. Avoid memmove for + each line. + 2008-04-22 Marcus Brinkmann * w32-qt-io.cpp, kdpipeiodevice.cpp: New versions from Frank diff --git a/trunk/gpgme/engine-gpgconf.c b/trunk/gpgme/engine-gpgconf.c index ab03e9d..456f330 100644 --- a/trunk/gpgme/engine-gpgconf.c +++ b/trunk/gpgme/engine-gpgconf.c @@ -198,7 +198,7 @@ gpgconf_read (void *engine, char *arg1, char *arg2, struct engine_gpgconf *gpgconf = engine; gpgme_error_t err = 0; #define LINELENGTH 1024 - char line[LINELENGTH] = ""; + char linebuf[LINELENGTH] = ""; int linelen = 0; char *argv[] = { NULL /* file_name */, arg1, arg2, 0 }; int rp[2]; @@ -229,28 +229,33 @@ gpgconf_read (void *engine, char *arg1, char *arg2, do { - nread = _gpgme_io_read (rp[0], &line[linelen], LINELENGTH - linelen - 1); + nread = _gpgme_io_read (rp[0], + linebuf + linelen, LINELENGTH - linelen - 1); if (nread > 0) { + char *line; + const char *lastmark = NULL; + size_t nused; + linelen += nread; - line[linelen] = '\0'; + linebuf[linelen] = '\0'; - while ((mark = strchr (line, '\n'))) + for (line=linebuf; (mark = strchr (line, '\n')); line = mark+1 ) { - char *eol = mark; - - if (eol > line && eol[-1] == '\r') - eol--; - *eol = '\0'; + lastmark = mark; + if (mark > line && mark[-1] == '\r') + mark--; + *mark = '\0'; /* Got a full line. */ err = (*cb) (hook, line); if (err) - break; - - linelen -= mark + 1 - line; - memmove (line, mark + 1, linelen); + goto leave; } + + nused = lastmark? (lastmark + 1 - linebuf) : 0; + memmove (linebuf, linebuf + nused, nused); + linelen -= nused; } } while (nread > 0 && linelen < LINELENGTH - 1); @@ -260,6 +265,7 @@ gpgconf_read (void *engine, char *arg1, char *arg2, if (!err && nread > 0) err = gpg_error (GPG_ERR_LINE_TOO_LONG); + leave: _gpgme_io_close (rp[0]); return err; diff --git a/trunk/gpgme/gpgme.h b/trunk/gpgme/gpgme.h index 8ae4daf..af6b239 100644 --- a/trunk/gpgme/gpgme.h +++ b/trunk/gpgme/gpgme.h @@ -72,7 +72,7 @@ extern "C" { AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.1.7-svn1301" +#define GPGME_VERSION "1.1.7-svn1307"