diff --git a/encfs/FileUtils.cpp b/encfs/FileUtils.cpp index edd2b71..f50d007 100644 --- a/encfs/FileUtils.cpp +++ b/encfs/FileUtils.cpp @@ -956,9 +956,7 @@ RootPtr createV6Config(EncFS_Context *ctx, const std::string passwordProgram = opts->passwordProgram; bool useStdin = opts->useStdin; bool reverseEncryption = opts->reverseEncryption; - ConfigMode configMode = (useStdin && - opts->configMode == Config_Prompt) ? Config_Standard - : opts->configMode; + ConfigMode configMode = opts->configMode; bool annotate = opts->annotate; RootPtr rootInfo; @@ -1171,9 +1169,6 @@ RootPtr createV6Config(EncFS_Context *ctx, else userKey = config->getNewUserKey(); - if (userKey == nullptr) - return rootInfo; - cipher->writeKey(volumeKey, encodedKey, userKey); userKey.reset(); @@ -1353,6 +1348,11 @@ CipherKey EncFSConfig::makeKey(const char *password, int passwdLen) { CipherKey userKey; std::shared_ptr cipher = getCipher(); + if (passwdLen == 0) { + cerr << _("fatal: zero-length passwords are not allowed\n"); + exit(1); + } + // if no salt is set and we're creating a new password for a new // FS type, then initialize salt.. if (salt.size() == 0 && kdfIterations == 0 && cfgType >= Config_V6) { @@ -1394,10 +1394,12 @@ CipherKey EncFSConfig::getUserKey(bool useStdin) { } CipherKey userKey; - if (!res) - cerr << _("Zero length password not allowed\n"); - else + if (!res) { + cerr << _("fatal: error reading password\n"); + exit(1); + } else { userKey = makeKey(passBuf, strlen(passBuf)); + } memset(passBuf, 0, sizeof(passBuf));