1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-04-17 15:44:34 +02:00

* app-openpgp.c (get_cached_data): Avoid mallocing zero since it breaks us

when using --enable-m-guard.
This commit is contained in:
David Shaw 2004-09-11 03:30:48 +00:00
parent b700d3cd3e
commit dccd0d991b
2 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,8 @@
2004-09-10 David Shaw <dshaw@jabberwocky.com> 2004-09-10 David Shaw <dshaw@jabberwocky.com>
* app-openpgp.c (get_cached_data): Avoid mallocing zero since it
breaks us when using --enable-m-guard.
* ccid-driver.c (read_device_info): Fix segfault when usb device * ccid-driver.c (read_device_info): Fix segfault when usb device
is not accessible. is not accessible.
(ccid_open_reader): Allow working with an even older version of (ccid_open_reader): Allow working with an even older version of

View File

@ -124,7 +124,6 @@ get_cached_data (app_t app, int tag,
size_t len; size_t len;
struct cache_s *c; struct cache_s *c;
*result = NULL; *result = NULL;
*resultlen = 0; *resultlen = 0;
@ -132,13 +131,18 @@ get_cached_data (app_t app, int tag,
{ {
for (c=app->app_local->cache; c; c = c->next) for (c=app->app_local->cache; c; c = c->next)
if (c->tag == tag) if (c->tag == tag)
{
if(c->length)
{ {
p = xtrymalloc (c->length); p = xtrymalloc (c->length);
if (!p) if (!p)
return gpg_error (gpg_err_code_from_errno (errno)); return gpg_error (gpg_err_code_from_errno (errno));
memcpy (p, c->data, c->length); memcpy (p, c->data, c->length);
*resultlen = c->length;
*result = p; *result = p;
}
*resultlen = c->length;
return 0; return 0;
} }
} }