Fixed issue with member access

This is kind of hacky, but it avoids the segfault at runtime. So,
preferrable. If we ever have more options, we need to properly generate
the argv[] array.
This commit is contained in:
Johannes Bauer 2021-06-27 12:32:44 +02:00
parent b0fc16bfc7
commit 37b239b179
2 changed files with 9 additions and 13 deletions

View File

@ -6,7 +6,7 @@ INSTALL_PREFIX := /usr/local/
CFLAGS := -Wall -Wextra -Wshadow -Wswitch -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Werror=implicit-function-declaration -Werror=format -Wno-unused-parameter
CFLAGS += -O3 -std=c11 -pthread -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=500 -DBUILD_REVISION='"$(BUILD_REVISION)"'
CFLAGS += `pkg-config --cflags openssl`
CFLAGS += -ggdb3 -DDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak
#CFLAGS += -ggdb3 -DDEBUG -fsanitize=address -fsanitize=undefined -fsanitize=leak
PYPGMOPTS := ../Python/pypgmopts/pypgmopts
LDFLAGS := `pkg-config --libs openssl`

20
luks.c
View File

@ -57,22 +57,15 @@ bool open_luks_device(const uint8_t *encrypted_device_uuid, const char *mapping_
log_msg(LLVL_INFO, "Trying to unlock LUKS mapping %s based on %s", mapping_name, encrypted_device);
struct exec_cmd_t cmd = {
.stdin_data = passphrase,
.stdin_length = passphrase_length,
.show_output = should_log(LLVL_DEBUG),
};
if (!allow_discards) {
cmd.argv = (const char *[]) {
.argv = !allow_discards ? (const char *[]) {
"cryptsetup",
"luksOpen",
"-T", "1",
encrypted_device,
mapping_name,
NULL,
};
} else {
cmd.argv = (const char *[]) {
} :
(const char *[]) {
"cryptsetup",
"--allow-discards",
"luksOpen",
@ -80,8 +73,11 @@ bool open_luks_device(const uint8_t *encrypted_device_uuid, const char *mapping_
encrypted_device,
mapping_name,
NULL,
};
}
},
.stdin_data = passphrase,
.stdin_length = passphrase_length,
.show_output = should_log(LLVL_DEBUG),
};
struct exec_result_t runresult = exec_command(&cmd);
return runresult.success && (runresult.returncode == 0);