mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
sm: Fix error checking of decryption result.
* sm/call-agent.c (gpgsm_agent_pkdecrypt): Fix condition. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
3ba091ab8c
commit
15fe78184c
@ -528,7 +528,8 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
put_membuf (&data, "", 1); /* Make sure it is 0 terminated so we can invoke strtoul safely. */
|
/* Make sure it is 0 terminated so we can invoke strtoul safely. */
|
||||||
|
put_membuf (&data, "", 1);
|
||||||
buf = get_membuf (&data, &len);
|
buf = get_membuf (&data, &len);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return gpg_error (GPG_ERR_ENOMEM);
|
return gpg_error (GPG_ERR_ENOMEM);
|
||||||
@ -544,14 +545,14 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
|
|||||||
if (buf[len-1] != ')')
|
if (buf[len-1] != ')')
|
||||||
return gpg_error (GPG_ERR_INV_SEXP);
|
return gpg_error (GPG_ERR_INV_SEXP);
|
||||||
len--; /* Drop the final close-paren: */
|
len--; /* Drop the final close-paren: */
|
||||||
p = buf + 8; /* Skip leading parenthesis and the value tag. */
|
p = buf + 8; /* Skip leading parenthesis and the value tag. */
|
||||||
len -= 8; /* Count only the data of the second part. */
|
len -= 8; /* Count only the data of the second part. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* For compatibility with older gpg-agents handle the old style
|
/* For compatibility with older gpg-agents handle the old style
|
||||||
incomplete S-exps. */
|
incomplete S-exps. */
|
||||||
len--; /* Do not count the Nul. */
|
len--; /* Do not count the Nul. */
|
||||||
p = buf;
|
p = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,8 +560,8 @@ gpgsm_agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
|
|||||||
if (!n || *endp != ':')
|
if (!n || *endp != ':')
|
||||||
return gpg_error (GPG_ERR_INV_SEXP);
|
return gpg_error (GPG_ERR_INV_SEXP);
|
||||||
endp++;
|
endp++;
|
||||||
if (endp-p+n > len)
|
if (endp-p+n != len)
|
||||||
return gpg_error (GPG_ERR_INV_SEXP); /* Oops: Inconsistent S-Exp. */
|
return gpg_error (GPG_ERR_INV_SEXP); /* Oops: Inconsistent S-Exp. */
|
||||||
|
|
||||||
memmove (buf, endp, n);
|
memmove (buf, endp, n);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user