streaming: stream_session: do not log err.c_str verbatim

It is dangerous to print a formatted string as is, like
sslog.warn(err.c_str()) since it might hold curly braces ('{}')
and those require respective runtime args.

Instead, it should be logged as e.g. sslog.warn("{}", err.c_str()).

This will prevent issues like #8436.

Refs #8436

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Message-Id: <20210408173048.124417-2-bhalevy@scylladb.com>
This commit is contained in:
Benny Halevy
2021-04-08 20:30:48 +03:00
committed by Avi Kivity
parent 76cd315c42
commit 830128cd95

View File

@@ -91,13 +91,13 @@ static auto get_session(utils::UUID plan_id, gms::inet_address from, const char*
auto sr = get_stream_result_future(plan_id);
if (!sr) {
auto err = format("[Stream #{}] GOT {} from {}: Can not find stream_manager", plan_id, verb, from);
sslog.debug(err.c_str());
sslog.debug("{}", err.c_str());
throw std::runtime_error(err);
}
auto coordinator = sr->get_coordinator();
if (!coordinator) {
auto err = format("[Stream #{}] GOT {} from {}: Can not find coordinator", plan_id, verb, from);
sslog.debug(err.c_str());
sslog.debug("{}", err.c_str());
throw std::runtime_error(err);
}
return coordinator->get_or_create_session(from);
@@ -382,7 +382,7 @@ future<prepare_message> stream_session::prepare(std::vector<stream_request> requ
db.find_column_family(ks, cf);
} catch (no_such_column_family&) {
auto err = format("[Stream #{}] prepare requested ks={} cf={} does not exist", plan_id, ks, cf);
sslog.warn(err.c_str());
sslog.warn("{}", err.c_str());
throw std::runtime_error(err);
}
}
@@ -396,7 +396,7 @@ future<prepare_message> stream_session::prepare(std::vector<stream_request> requ
db.find_column_family(cf_id);
} catch (no_such_column_family&) {
auto err = format("[Stream #{}] prepare cf_id={} does not exist", plan_id, cf_id);
sslog.warn(err.c_str());
sslog.warn("{}", err.c_str());
throw std::runtime_error(err);
}
prepare_receiving(summary);