Now limit the file identifier to a). has a length no longer than the value defined in knobs; b). can only contain [A-Za-z0-9_] chars.
This commit is contained in:
parent
b3997172e5
commit
459c2e34cd
|
@ -27,6 +27,7 @@ ClientKnobs const* CLIENT_KNOBS = new ClientKnobs();
|
|||
#define init( knob, value ) initKnob( knob, value, #knob )
|
||||
|
||||
ClientKnobs::ClientKnobs(bool randomize) {
|
||||
// clang-format off
|
||||
// FIXME: These are not knobs, get them out of ClientKnobs!
|
||||
BYTE_LIMIT_UNLIMITED = GetRangeLimits::BYTE_LIMIT_UNLIMITED;
|
||||
ROW_LIMIT_UNLIMITED = GetRangeLimits::ROW_LIMIT_UNLIMITED;
|
||||
|
@ -209,4 +210,8 @@ ClientKnobs::ClientKnobs(bool randomize) {
|
|||
//fdbcli
|
||||
init( CLI_CONNECT_PARALLELISM, 400 );
|
||||
init( CLI_CONNECT_TIMEOUT, 10.0 );
|
||||
|
||||
// trace
|
||||
init( TRACE_LOG_FILE_IDENTIFIER_MAX_LENGTH, 1024);
|
||||
// clang-format on
|
||||
}
|
||||
|
|
|
@ -200,6 +200,9 @@ public:
|
|||
int CLI_CONNECT_PARALLELISM;
|
||||
double CLI_CONNECT_TIMEOUT;
|
||||
|
||||
// trace
|
||||
int TRACE_LOG_FILE_IDENTIFIER_MAX_LENGTH;
|
||||
|
||||
ClientKnobs(bool randomize = false);
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "fdbclient/NativeAPI.actor.h"
|
||||
|
||||
#include <iterator>
|
||||
#include <regex>
|
||||
|
||||
#include "fdbclient/Atomic.h"
|
||||
#include "fdbclient/ClusterInterface.h"
|
||||
|
@ -843,6 +844,7 @@ const UniqueOrderedOptionList<FDBTransactionOptions>& Database::getTransactionDe
|
|||
}
|
||||
|
||||
void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> value) {
|
||||
std::regex identifierRegex("^[a-zA-Z0-9_]*$");
|
||||
switch(option) {
|
||||
// SOMEDAY: If the network is already started, should these three throw an error?
|
||||
case FDBNetworkOptions::TRACE_ENABLE:
|
||||
|
@ -879,6 +881,13 @@ void setNetworkOption(FDBNetworkOptions::Option option, Optional<StringRef> valu
|
|||
case FDBNetworkOptions::TRACE_FILE_IDENTIFIER:
|
||||
validateOptionValue(value, true);
|
||||
networkOptions.traceFileIdentifier = value.get().toString();
|
||||
if (networkOptions.traceFileIdentifier.length() > CLIENT_KNOBS->TRACE_LOG_FILE_IDENTIFIER_MAX_LENGTH) {
|
||||
fprintf(stderr, "Trace file identifier provided is too long.\n");
|
||||
throw invalid_option_value();
|
||||
} else if (!std::regex_match(networkOptions.traceFileIdentifier, identifierRegex)) {
|
||||
fprintf(stderr, "Trace file identifier should only contain alphanumerics and underscores.\n");
|
||||
throw invalid_option_value();
|
||||
}
|
||||
break;
|
||||
case FDBNetworkOptions::KNOB: {
|
||||
validateOptionValue(value, true);
|
||||
|
|
Loading…
Reference in New Issue