Fixed a bug reading from gpgconf.
This commit is contained in:
parent
a69c74e4ef
commit
914ace7a37
@ -1,3 +1,7 @@
|
||||
2008-04-01 Werner Koch <wk@g10code.com>
|
||||
|
||||
* configure.ac (AC_INIT): Fix quoting.
|
||||
|
||||
2008-01-30 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* configure.ac: Bump required version of automake up to 1.10.
|
||||
|
@ -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])
|
||||
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2008-04-28 Werner Koch <wk@g10code.com>
|
||||
|
||||
* engine-gpgconf.c (gpgconf_read): Fixed segv. Avoid memmove for
|
||||
each line.
|
||||
|
||||
2008-04-22 Marcus Brinkmann <marcus@g10code.de>
|
||||
|
||||
* w32-qt-io.cpp, kdpipeiodevice.cpp: New versions from Frank
|
||||
|
@ -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;
|
||||
|
@ -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"
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user