2008-02-15 Marcus Brinkmann <marcus@g10code.de>

* engine-gpgconf.c (gpgconf_read): Fix end-of-line handline.
This commit is contained in:
Marcus Brinkmann 2008-02-15 23:07:29 +00:00
parent ca17a12d3a
commit 8b83471079
2 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2008-02-15 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgconf.c (gpgconf_read): Fix end-of-line handline.
2008-02-14 Werner Koch <wk@g10code.com> 2008-02-14 Werner Koch <wk@g10code.com>
* w32-io.c (_gpgme_io_spawn): Add arg R_PID to return the pid. * w32-io.c (_gpgme_io_spawn): Add arg R_PID to return the pid.

View File

@ -232,24 +232,24 @@ gpgconf_read (void *engine, char *arg1, char *arg2,
nread = _gpgme_io_read (rp[0], &line[linelen], LINELENGTH - linelen - 1); nread = _gpgme_io_read (rp[0], &line[linelen], LINELENGTH - linelen - 1);
if (nread > 0) if (nread > 0)
{ {
line[linelen + nread] = '\0';
linelen += nread; linelen += nread;
line[linelen] = '\0';
while ((mark = strchr (line, '\n'))) while ((mark = strchr (line, '\n')))
{ {
char *eol = mark; char *eol = mark;
if (eol > &line[0] && *eol == '\r') if (eol > line && eol[-1] == '\r')
eol--; eol--;
*eol = '\0'; *eol = '\0';
/* Got a full line. */ /* Got a full line. */
err = (*cb) (hook, line); err = (*cb) (hook, line);
if (err) if (err)
break; break;
linelen -= mark - line; linelen -= mark + 1 - line;
memmove (line, eol + 1, linelen); memmove (line, mark + 1, linelen);
} }
} }
} }