|
@@ -700,17 +700,20 @@ static int peerblk_parse_header ( struct peerdist_block *peerblk ) {
|
700
|
700
|
return -EPROTO;
|
701
|
701
|
}
|
702
|
702
|
|
703
|
|
- /* Allocate cipher context. Freeing the cipher context (on
|
704
|
|
- * error or otherwise) is handled by peerblk_reset().
|
|
703
|
+ /* Allocate cipher context, if applicable. Freeing the cipher
|
|
704
|
+ * context (on error or otherwise) is handled by peerblk_reset().
|
705
|
705
|
*/
|
706
|
706
|
peerblk->cipher = cipher;
|
707
|
707
|
assert ( peerblk->cipherctx == NULL );
|
708
|
|
- peerblk->cipherctx = malloc ( cipher->ctxsize );
|
709
|
|
- if ( ! peerblk->cipherctx )
|
710
|
|
- return -ENOMEM;
|
|
708
|
+ if ( cipher ) {
|
|
709
|
+ peerblk->cipherctx = malloc ( cipher->ctxsize );
|
|
710
|
+ if ( ! peerblk->cipherctx )
|
|
711
|
+ return -ENOMEM;
|
|
712
|
+ }
|
711
|
713
|
|
712
|
|
- /* Initialise cipher */
|
713
|
|
- if ( ( rc = cipher_setkey ( cipher, peerblk->cipherctx, peerblk->secret,
|
|
714
|
+ /* Initialise cipher, if applicable */
|
|
715
|
+ if ( cipher &&
|
|
716
|
+ ( rc = cipher_setkey ( cipher, peerblk->cipherctx, peerblk->secret,
|
714
|
717
|
keylen ) ) != 0 ) {
|
715
|
718
|
DBGC ( peerblk, "PEERBLK %p %d.%d could not set key: %s\n",
|
716
|
719
|
peerblk, peerblk->segment, peerblk->block,
|