mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-05 16:00:05 +01:00
Get page size should never fail (in the works case it fails later with wrong alignment).
This commit is contained in:
@@ -471,16 +471,12 @@ static int TCRYPT_init_hdr(struct crypt_device *cd,
|
||||
struct crypt_params_tcrypt *params)
|
||||
{
|
||||
unsigned char pwd[TCRYPT_KEY_POOL_LEN] = {};
|
||||
size_t passphrase_size, alignment;
|
||||
size_t passphrase_size;
|
||||
char *key;
|
||||
unsigned int i, skipped = 0;
|
||||
int r = -EINVAL, legacy_modes;
|
||||
|
||||
alignment = crypt_getpagesize();
|
||||
if (alignment < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (posix_memalign((void*)&key, alignment, TCRYPT_HDR_KEY_LEN))
|
||||
if (posix_memalign((void*)&key, crypt_getpagesize(), TCRYPT_HDR_KEY_LEN))
|
||||
return -ENOMEM;
|
||||
|
||||
if (params->keyfiles_count)
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
|
||||
unsigned crypt_getpagesize(void)
|
||||
{
|
||||
return (unsigned)sysconf(_SC_PAGESIZE);
|
||||
long r = sysconf(_SC_PAGESIZE);
|
||||
return r < 0 ? DEFAULT_MEM_ALIGNMENT : r;
|
||||
}
|
||||
|
||||
static int get_alignment(int fd)
|
||||
|
||||
@@ -128,14 +128,9 @@ static int cipher_perf(struct cipher_perf *cp,
|
||||
{
|
||||
long ms_enc, ms_dec, ms;
|
||||
int repeat_enc, repeat_dec;
|
||||
size_t alignment;
|
||||
void *buf = NULL;
|
||||
|
||||
alignment = crypt_getpagesize();
|
||||
if (alignment < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (posix_memalign(&buf, alignment, cp->buffer_size))
|
||||
if (posix_memalign(&buf, crypt_getpagesize(), cp->buffer_size))
|
||||
return -ENOMEM;
|
||||
|
||||
ms_enc = 0;
|
||||
|
||||
Reference in New Issue
Block a user