Use memcpy instead of manually copying data

Let the standard memcpy function taking care of copying the
random data to the caller-supplied buffer.

In the (unlikely?) event we got more bytes from the daemon than
we requested, return an error instead of silently ignoring it.
develop
Damien Goutte-Gattat 7 years ago
parent 8f93501656
commit 04ee54cd55
  1. 9
      src/scdrand.c

@ -112,13 +112,12 @@ struct challenge
gpg_error_t
get_challenge_data_cb(void *arg, const void *line, size_t len)
{
struct challenge *c;
unsigned i;
struct challenge *c = arg;
c = (struct challenge *)arg;
if ( len > c->len )
return gpg_error(GPG_ERR_INV_LENGTH);
for ( i = 0; i < len && i < c->len; i++ )
c->data[i] = ((const unsigned char *)line)[i];
memcpy(c->data, line, len);
c->len = len;
return 0;

Loading…
Cancel
Save