a4b143
From c201b69ff022a9527323d2445b11861ccbf3cfad Mon Sep 17 00:00:00 2001
a4b143
From: Lennart Poettering <lennart@poettering.net>
a4b143
Date: Wed, 2 Oct 2013 19:36:28 +0200
a4b143
Subject: [PATCH] cryptsetup: fix OOM handling when parsing mount options
a4b143
a4b143
---
a4b143
 src/cryptsetup/cryptsetup.c | 11 ++++++-----
a4b143
 1 file changed, 6 insertions(+), 5 deletions(-)
a4b143
a4b143
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
a4b143
index 22b5eea..769c3e4 100644
a4b143
--- a/src/cryptsetup/cryptsetup.c
a4b143
+++ b/src/cryptsetup/cryptsetup.c
a4b143
@@ -74,7 +74,7 @@ static int parse_one_option(const char *option) {
a4b143
 
a4b143
                 t = strdup(option+7);
a4b143
                 if (!t)
a4b143
-                        return -ENOMEM;
a4b143
+                        return log_oom();
a4b143
 
a4b143
                 free(opt_cipher);
a4b143
                 opt_cipher = t;
a4b143
@@ -89,9 +89,10 @@ static int parse_one_option(const char *option) {
a4b143
         } else if (startswith(option, "tcrypt-keyfile=")) {
a4b143
 
a4b143
                 opt_type = CRYPT_TCRYPT;
a4b143
-                if (path_is_absolute(option+15))
a4b143
-                        opt_tcrypt_keyfiles = strv_append(opt_tcrypt_keyfiles, strdup(option+15));
a4b143
-                else
a4b143
+                if (path_is_absolute(option+15)) {
a4b143
+                        if (strv_extend(&opt_tcrypt_keyfiles, option + 15) < 0)
a4b143
+                                return log_oom();
a4b143
+                } else
a4b143
                         log_error("Key file path '%s' is not absolute. Ignoring.", option+15);
a4b143
 
a4b143
         } else if (startswith(option, "keyfile-size=")) {
a4b143
@@ -113,7 +114,7 @@ static int parse_one_option(const char *option) {
a4b143
 
a4b143
                 t = strdup(option+5);
a4b143
                 if (!t)
a4b143
-                        return -ENOMEM;
a4b143
+                        return log_oom();
a4b143
 
a4b143
                 free(opt_hash);
a4b143
                 opt_hash = t;