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