core: Fix status error return for gpgsm.
* src/engine-gpgsm.c (gpgsm_assuan_simple_command): Make sure CB_ERR is returned. * src/import.c (parse_import_res): Do not return an error for the last field. (import_status_handler): Actually return the error from parse_import_res. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
41398779ab
commit
d2240a2a18
@ -593,7 +593,7 @@ gpgsm_assuan_simple_command (engine_gpgsm_t gpgsm, const char *cmd,
|
|||||||
{
|
{
|
||||||
err = assuan_read_line (ctx, &line, &linelen);
|
err = assuan_read_line (ctx, &line, &linelen);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
break;
|
||||||
|
|
||||||
if (*line == '#' || !linelen)
|
if (*line == '#' || !linelen)
|
||||||
continue;
|
continue;
|
||||||
@ -601,7 +601,7 @@ gpgsm_assuan_simple_command (engine_gpgsm_t gpgsm, const char *cmd,
|
|||||||
if (linelen >= 2
|
if (linelen >= 2
|
||||||
&& line[0] == 'O' && line[1] == 'K'
|
&& line[0] == 'O' && line[1] == 'K'
|
||||||
&& (line[2] == '\0' || line[2] == ' '))
|
&& (line[2] == '\0' || line[2] == ' '))
|
||||||
return cb_err;
|
break;
|
||||||
else if (linelen >= 4
|
else if (linelen >= 4
|
||||||
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
|
&& line[0] == 'E' && line[1] == 'R' && line[2] == 'R'
|
||||||
&& line[3] == ' ')
|
&& line[3] == ' ')
|
||||||
@ -610,6 +610,7 @@ gpgsm_assuan_simple_command (engine_gpgsm_t gpgsm, const char *cmd,
|
|||||||
more related to gpgme and thus probably more important
|
more related to gpgme and thus probably more important
|
||||||
than the error returned by the engine. */
|
than the error returned by the engine. */
|
||||||
err = cb_err? cb_err : atoi (&line[4]);
|
err = cb_err? cb_err : atoi (&line[4]);
|
||||||
|
cb_err = 0;
|
||||||
}
|
}
|
||||||
else if (linelen >= 2
|
else if (linelen >= 2
|
||||||
&& line[0] == 'S' && line[1] == ' ')
|
&& line[0] == 'S' && line[1] == ' ')
|
||||||
@ -646,10 +647,16 @@ gpgsm_assuan_simple_command (engine_gpgsm_t gpgsm, const char *cmd,
|
|||||||
to stop. As with ERR we prefer a status callback
|
to stop. As with ERR we prefer a status callback
|
||||||
generated error code, though. */
|
generated error code, though. */
|
||||||
err = cb_err ? cb_err : gpg_error (GPG_ERR_GENERAL);
|
err = cb_err ? cb_err : gpg_error (GPG_ERR_GENERAL);
|
||||||
|
cb_err = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (!err);
|
while (!err);
|
||||||
|
|
||||||
|
/* We only want the first error from the status handler, thus we
|
||||||
|
* take the one saved in CB_ERR. */
|
||||||
|
if (!err && cb_err)
|
||||||
|
err = cb_err;
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ parse_import_res (char *args, gpgme_import_result_t result)
|
|||||||
|
|
||||||
#define PARSE_NEXT(x) \
|
#define PARSE_NEXT(x) \
|
||||||
(x) = strtol (args, &tail, 0); \
|
(x) = strtol (args, &tail, 0); \
|
||||||
if (errno || args == tail || *tail != ' ') \
|
if (errno || args == tail || !(*tail == ' ' || !*tail)) \
|
||||||
/* The crypto backend does not behave. */ \
|
/* The crypto backend does not behave. */ \
|
||||||
return trace_gpg_error (GPG_ERR_INV_ENGINE); \
|
return trace_gpg_error (GPG_ERR_INV_ENGINE); \
|
||||||
args = tail;
|
args = tail;
|
||||||
@ -249,7 +249,7 @@ import_status_handler (void *priv, gpgme_status_code_t code, char *args)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user