Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion obs-studio-server/source/osn-advanced-recording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#include "shared.hpp"
#include "osn-audio-track.hpp"
#include "osn-file-output.hpp"
#include <osn-encoders.hpp>
#include "osn-encoders.hpp"
#include <util/platform.h>

void osn::IAdvancedRecording::Register(ipc::server &srv)
{
Expand Down Expand Up @@ -282,6 +283,14 @@ void osn::IAdvancedRecording::Start(void *data, const int64_t id, const std::vec

obs_output_set_video_encoder(recording->GetOutput(), recording->videoEncoder);

if (!recording->path.size()) {
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
}

if (!os_is_path_safe(recording->path.c_str())) {
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
}

std::string path = recording->path;

char lastChar = path.back();
Expand Down
5 changes: 5 additions & 0 deletions obs-studio-server/source/osn-advanced-replay-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "shared.hpp"
#include "osn-audio-track.hpp"
#include "osn-encoders.hpp"
#include <util/platform.h>

void osn::IAdvancedReplayBuffer::Register(ipc::server &srv)
{
Expand Down Expand Up @@ -205,6 +206,10 @@ void osn::IAdvancedReplayBuffer::Start(void *data, const int64_t id, const std::
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
}

if (!os_is_path_safe(replayBuffer->path.c_str())) {
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
}

const char *rbPrefix = replayBuffer->prefix.c_str();
const char *rbSuffix = replayBuffer->suffix.c_str();
int64_t rbSize = replayBuffer->usesStream ? 0 : 512;
Expand Down
5 changes: 5 additions & 0 deletions obs-studio-server/source/osn-simple-recording.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "nodeobs_audio_encoders.h"
#include "osn-file-output.hpp"
#include "osn-encoders.hpp"
#include <util/platform.h>

void osn::ISimpleRecording::Register(ipc::server &srv)
{
Expand Down Expand Up @@ -401,6 +402,10 @@ void osn::ISimpleRecording::Start(void *data, const int64_t id, const std::vecto
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
}

if (!os_is_path_safe(recording->path.c_str())) {
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
}

std::string path = recording->path;

char lastChar = path.back();
Expand Down
7 changes: 6 additions & 1 deletion obs-studio-server/source/osn-simple-replay-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "shared.hpp"
#include "nodeobs_audio_encoders.h"
#include "osn-encoders.hpp"
#include <util/platform.h>

void osn::ISimpleReplayBuffer::Register(ipc::server &srv)
{
Expand Down Expand Up @@ -147,6 +148,10 @@ void osn::ISimpleReplayBuffer::Start(void *data, const int64_t id, const std::ve
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
}

if (!os_is_path_safe(replayBuffer->path.c_str())) {
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
}

const char *rbPrefix = replayBuffer->prefix.c_str();
const char *rbSuffix = replayBuffer->suffix.c_str();
int64_t rbSize = replayBuffer->usesStream ? 0 : 512;
Expand Down Expand Up @@ -312,4 +317,4 @@ void osn::ISimpleReplayBuffer::SetRecording(void *data, const int64_t id, const

rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
AUTO_DEBUG;
}
}
Loading