Browse Source

Fix a few stupid errors in splitting code

master
Damien Goutte-Gattat 5 years ago
parent
commit
c6237d6fee
  1. 8
      src/secret.c

8
src/secret.c

@ -314,7 +314,7 @@ gfsec_secret_set_secret_file(gfsec_secret_t *secret,
if ( ! secret || ! filename )
return GFSEC_ERR_INVALID_CALL;
if ( (secret->filename = strdup(filename)) )
if ( ! (secret->filename = strdup(filename)) )
return GFSEC_ERR_SYSTEM_ERROR;
if ( ! (secret->data = read_file(filename, &(secret->len),
@ -500,7 +500,7 @@ gfsec_secret_get_partial_share_count(gfsec_secret_t *secret)
unsigned u, n;
for ( u = n = 0; u < secret->n_shares; u++ )
if ( gfsec_share_is_full(secret->shares[u]) )
if ( ! gfsec_share_is_full(secret->shares[u]) )
n += 1;
return n;
@ -548,7 +548,7 @@ gfsec_secret_split(gfsec_secret_t *secret, unsigned char threshold)
if ( ! (share->data = malloc(secret->len)) )
rc = GFSEC_ERR_SYSTEM_ERROR;
if ( ! (share->data = malloc(32)) )
if ( ! (share->hash = malloc(32)) )
rc = GFSEC_ERR_SYSTEM_ERROR;
}
@ -565,7 +565,7 @@ gfsec_secret_split(gfsec_secret_t *secret, unsigned char threshold)
for ( u = v = 0; u < secret->n_shares; u++ ) {
share = secret->shares[u];
if ( gfsec_share_is_full(share) )
if ( ! gfsec_share_is_full(share) )
gfshare_ctx_enc_getshare(ctx, v++, share->data);
else
memcpy(share->data, secret->data, secret->len);

Loading…
Cancel
Save