if (!(hash_id = gcry_md_map_name(hash)))
return -EINVAL;
- if((bufblock = calloc(blocksize, 1)) == NULL) return -ENOMEM;
+ if((bufblock = calloc(blocksize, 1)) == NULL)
+ return -ENOMEM;
memset(bufblock,0,blocksize);
for(i=0; i<blocknumbers-1; i++) {
r = 0;
out:
free(bufblock);
- return 0;
+ return r;
}
r = crypt_dump(cd);
crypt_free(cd);
- return 0;
+ return r;
}
void crypt_get_error(char *buf, size_t size)
if (!r) {
memcpy(&cd->hdr, &hdr, sizeof(hdr));
- cd->type = strdup(requested_type);
+ cd->type = strdup(CRYPT_LUKS1);
if (!cd->type)
r = -ENOMEM;
}
crypt_status_info ci;
struct volume_key *vk = NULL;
char *read_passphrase = NULL;
+ unsigned int passphraseLen = 0;
int r;
log_dbg("%s volume %s [keyslot %d] using %spassphrase.",
if (isPLAIN(cd->type)) {
if (!passphrase) {
r = key_from_terminal(cd, NULL, &read_passphrase,
- &passphrase_size, 0);
+ &passphraseLen, 0);
if (r < 0)
goto out;
passphrase = read_passphrase;
+ passphrase_size = passphraseLen;
}
r = create_device_helper(cd, name, cd->plain_hdr.hash,
cd->plain_cipher, cd->plain_cipher_mode,
if ((long)orig_buf & (alignment - 1)) {
buf = aligned_malloc(&buf_base, count, alignment);
if (!buf)
- goto out;
+ return -1;
} else
buf = orig_buf;
tcsetattr(infd, TCSAFLUSH, &orig);
out_err:
- if (!failed && write(outfd, "\n", 1));
+ if (!failed && write(outfd, "\n", 1)) {};
if (infd != STDIN_FILENO)
close(infd);
int i;
pass = crypt_safe_alloc(MAX_TTY_PASSWORD_LEN);
- if (!pass || (i = interactive_pass(prompt, pass, MAX_TTY_PASSWORD_LEN, timeout))) {
+ if (!pass || interactive_pass(prompt, pass, MAX_TTY_PASSWORD_LEN, timeout)) {
crypt_log(cd, CRYPT_LOG_ERROR,
_("Error reading passphrase from terminal.\n"));
goto out_err;
return r;
}
-static void usage(poptContext popt_context, int exitcode,
- const char *error, const char *more)
+static __attribute__ ((noreturn)) void usage(poptContext popt_context,
+ int exitcode, const char *error,
+ const char *more)
{
poptPrintUsage(popt_context, stderr, 0);
if (error)
_("Key size must be a multiple of 8 bits"),
poptGetInvocationName(popt_context));
- if (!strcmp(aname, "luksKillSlot"))
+ if (!strcmp(aname, "luksKillSlot") && action_argc > 1)
opt_key_slot = atoi(action_argv[1]);
if (opt_key_slot != CRYPT_ANY_SLOT &&
(opt_key_slot < 0 || opt_key_slot > crypt_keyslot_max(CRYPT_LUKS1)))