Skip to content

Commit f55b76a

Browse files
committed
Validate recording output directories
1 parent f58db3e commit f55b76a

4 files changed

Lines changed: 11 additions & 4 deletions

File tree

obs-studio-server/source/osn-advanced-recording.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "osn-audio-track.hpp"
2323
#include "osn-file-output.hpp"
2424
#include <osn-encoders.hpp>
25+
#include <util/platform.h>
2526

2627
void osn::IAdvancedRecording::Register(ipc::server &srv)
2728
{
@@ -281,6 +282,9 @@ void osn::IAdvancedRecording::Start(void *data, const int64_t id, const std::vec
281282
}
282283

283284
obs_output_set_video_encoder(recording->GetOutput(), recording->videoEncoder);
285+
if (!recording->path.size() || !os_is_path_safe(recording->path.c_str())) {
286+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
287+
}
284288

285289
std::string path = recording->path;
286290

obs-studio-server/source/osn-advanced-replay-buffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "shared.hpp"
2323
#include "osn-audio-track.hpp"
2424
#include "osn-encoders.hpp"
25+
#include <util/platform.h>
2526

2627
void osn::IAdvancedReplayBuffer::Register(ipc::server &srv)
2728
{
@@ -201,7 +202,7 @@ void osn::IAdvancedReplayBuffer::Start(void *data, const int64_t id, const std::
201202

202203
obs_output_set_video_encoder(replayBuffer->GetOutput(), videoEncoder);
203204

204-
if (!replayBuffer->path.size()) {
205+
if (!replayBuffer->path.size() || !os_is_path_safe(replayBuffer->path.c_str())) {
205206
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
206207
}
207208

obs-studio-server/source/osn-simple-recording.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "nodeobs_audio_encoders.h"
2525
#include "osn-file-output.hpp"
2626
#include "osn-encoders.hpp"
27+
#include <util/platform.h>
2728

2829
void osn::ISimpleRecording::Register(ipc::server &srv)
2930
{
@@ -397,7 +398,7 @@ void osn::ISimpleRecording::Start(void *data, const int64_t id, const std::vecto
397398
obs_output_set_video_encoder(recording->GetOutput(), recording->videoEncoder);
398399
}
399400

400-
if (!recording->path.size()) {
401+
if (!recording->path.size() || !os_is_path_safe(recording->path.c_str())) {
401402
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
402403
}
403404

obs-studio-server/source/osn-simple-replay-buffer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "shared.hpp"
2323
#include "nodeobs_audio_encoders.h"
2424
#include "osn-encoders.hpp"
25+
#include <util/platform.h>
2526

2627
void osn::ISimpleReplayBuffer::Register(ipc::server &srv)
2728
{
@@ -143,7 +144,7 @@ void osn::ISimpleReplayBuffer::Start(void *data, const int64_t id, const std::ve
143144

144145
obs_output_set_video_encoder(replayBuffer->GetOutput(), videoEncoder);
145146

146-
if (!replayBuffer->path.size()) {
147+
if (!replayBuffer->path.size() || !os_is_path_safe(replayBuffer->path.c_str())) {
147148
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
148149
}
149150

@@ -312,4 +313,4 @@ void osn::ISimpleReplayBuffer::SetRecording(void *data, const int64_t id, const
312313

313314
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
314315
AUTO_DEBUG;
315-
}
316+
}

0 commit comments

Comments
 (0)