mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
agent: Make an MD encoding function more robust.
* agent/pksign.c (do_encode_md): Use ascii_tolower and avoid uninitalized TMP in the error case. -- This is just in case libgcrypt ever returns an algorithm name longer than 15 bytes. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
19415a2652
commit
a2a9071746
@ -44,16 +44,21 @@ do_encode_md (const byte * md, size_t mdlen, int algo, gcry_sexp_t * r_hash,
|
||||
int i;
|
||||
|
||||
s = gcry_md_algo_name (algo);
|
||||
if (s && strlen (s) < 16)
|
||||
if (!s || strlen (s) >= 16)
|
||||
{
|
||||
hash = NULL;
|
||||
rc = gpg_error (GPG_ERR_DIGEST_ALGO);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i < strlen (s); i++)
|
||||
tmp[i] = tolower (s[i]);
|
||||
for (i=0; s[i]; i++)
|
||||
tmp[i] = ascii_tolower (s[i]);
|
||||
tmp[i] = '\0';
|
||||
}
|
||||
|
||||
rc = gcry_sexp_build (&hash, NULL,
|
||||
"(data (flags pkcs1) (hash %s %b))",
|
||||
tmp, (int)mdlen, md);
|
||||
rc = gcry_sexp_build (&hash, NULL,
|
||||
"(data (flags pkcs1) (hash %s %b))",
|
||||
tmp, (int)mdlen, md);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user