X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcryptsetup%2Fcryptsetup.c;h=4f2f52a28a236f6fd03946eb494aa078eb899911;hb=f405e86de361ec305dc2b8634efeaa23dc144053;hp=22b5eead72d3e804557e602090f86cb781734527;hpb=404dac4d96f4aaf66026e8b412c4b67e8773cffa;p=elogind.git diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 22b5eead7..4f2f52a28 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; @@ -235,31 +236,24 @@ finish: } static char *disk_mount_point(const char *label) { - char *mp = NULL; _cleanup_free_ char *device = NULL; - FILE *f = NULL; + _cleanup_endmntent_ FILE *f = NULL; struct mntent *m; /* Yeah, we don't support native systemd unit files here for now */ if (asprintf(&device, "/dev/mapper/%s", label) < 0) - goto finish; + return NULL; f = setmntent("/etc/fstab", "r"); if (!f) - goto finish; + return NULL; while ((m = getmntent(f))) - if (path_equal(m->mnt_fsname, device)) { - mp = strdup(m->mnt_dir); - break; - } - -finish: - if (f) - endmntent(f); + if (path_equal(m->mnt_fsname, device)) + return strdup(m->mnt_dir); - return mp; + return NULL; } static int get_password(const char *name, usec_t until, bool accept_cached, char ***passwords) {