server : reject non-object session updates (#31714)
Prevent malformed realtime session updates from throwing an uncaught exception and terminating the server Signed-off-by: Adrien Gallouët <angt@huggingface.co>
This commit is contained in:
1 parent
2c192444c9
commit
c55b094880
1 file changed
+4
@@ -569,6 +569,10 @@ struct realtime_conversation {
|
||||
|
||||
void on_session_update(const json & ev) {
|
||||
const json session = ev.value("session", json::object());
|
||||
if (!session.is_object()) {
|
||||
send_error("session.update: session must be an object");
|
||||
return;
|
||||
}
|
||||
if (session.contains("type") && session["type"].is_string() && session["type"] != type) {
|
||||
const std::string t = session["type"];
|
||||
if (t != "realtime" && t != "transcription") {
|
||||
|
||||
Reference in new issue
Block a user