Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/mongo/db/auth/security_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ namespace mongo {
}
#endif

const unsigned long long fileLength = stats.st_size;
if (fileLength < 6 || fileLength > 1024) {
log() << " key file " << filename << " has length " << stats.st_size
<< ", must be between 6 and 1024 chars" << endl;
return false;
}

FILE* file = fopen( filename.c_str(), "rb" );
if (!file) {
log() << "error opening file: " << filename << ": " << strerror(errno) << endl;
Expand All @@ -94,6 +87,7 @@ namespace mongo {
string str = "";

// strip key file
const unsigned long long fileLength = stats.st_size;
unsigned long long read = 0;
while (read < fileLength) {
char buf;
Expand Down Expand Up @@ -122,8 +116,10 @@ namespace mongo {

fclose( file );

if (str.size() < 6) {
log() << "security key must be at least 6 characters" << endl;
const unsigned long long keyLength = str.size();
if (keyLength < 6 || keyLength > 1024) {
log() << " security key in " << filename << " has length " << keyLength
<< ", must be between 6 and 1024 chars" << endl;
return false;
}

Expand Down