summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-02 19:36:28 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-02 19:45:12 +0200
commit4b93637fd7dddb0a1518f35171998b2c7cd5c5bd (patch)
treec3b7b7ee95daa4a91189ff65e52444960b69f338 /src
parentcbb13b2a538ece1c7ec3b210e2b36b47df2a13ea (diff)
cryptsetup: fix OOM handling when parsing mount options
Diffstat (limited to 'src')
-rw-r--r--src/cryptsetup/cryptsetup.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 22b5eead72..769c3e4f31 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -74,7 +74,7 @@ static int parse_one_option(const char *option) {
t = strdup(option+7);
if (!t)
- return -ENOMEM;
+ return log_oom();
free(opt_cipher);
opt_cipher = t;
@@ -89,9 +89,10 @@ static int parse_one_option(const char *option) {
} else if (startswith(option, "tcrypt-keyfile=")) {
opt_type = CRYPT_TCRYPT;
- if (path_is_absolute(option+15))
- opt_tcrypt_keyfiles = strv_append(opt_tcrypt_keyfiles, strdup(option+15));
- else
+ if (path_is_absolute(option+15)) {
+ if (strv_extend(&opt_tcrypt_keyfiles, option + 15) < 0)
+ return log_oom();
+ } else
log_error("Key file path '%s' is not absolute. Ignoring.", option+15);
} else if (startswith(option, "keyfile-size=")) {
@@ -113,7 +114,7 @@ static int parse_one_option(const char *option) {
t = strdup(option+5);
if (!t)
- return -ENOMEM;
+ return log_oom();
free(opt_hash);
opt_hash = t;