Skip to content

Commit 014dd0f

Browse files
summeroffclaude
andcommitted
fix: report unsafe recording paths distinctly from invalid ones
Splitting the empty-path and os_is_path_safe() checks lets the IPC error and the log line say which one tripped, so a rejected symlink/junction directory is diagnosable instead of just "Invalid recording path." Also switch osn-encoders.hpp to a quoted include, matching every other consumer of that header. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent f55b76a commit 014dd0f

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "shared.hpp"
2222
#include "osn-audio-track.hpp"
2323
#include "osn-file-output.hpp"
24-
#include <osn-encoders.hpp>
24+
#include "osn-encoders.hpp"
2525
#include <util/platform.h>
2626

2727
void osn::IAdvancedRecording::Register(ipc::server &srv)
@@ -282,10 +282,15 @@ void osn::IAdvancedRecording::Start(void *data, const int64_t id, const std::vec
282282
}
283283

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

290+
if (!os_is_path_safe(recording->path.c_str())) {
291+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
292+
}
293+
289294
std::string path = recording->path;
290295

291296
char lastChar = path.back();

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,14 @@ void osn::IAdvancedReplayBuffer::Start(void *data, const int64_t id, const std::
202202

203203
obs_output_set_video_encoder(replayBuffer->GetOutput(), videoEncoder);
204204

205-
if (!replayBuffer->path.size() || !os_is_path_safe(replayBuffer->path.c_str())) {
205+
if (!replayBuffer->path.size()) {
206206
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
207207
}
208208

209+
if (!os_is_path_safe(replayBuffer->path.c_str())) {
210+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
211+
}
212+
209213
const char *rbPrefix = replayBuffer->prefix.c_str();
210214
const char *rbSuffix = replayBuffer->suffix.c_str();
211215
int64_t rbSize = replayBuffer->usesStream ? 0 : 512;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,14 @@ void osn::ISimpleRecording::Start(void *data, const int64_t id, const std::vecto
398398
obs_output_set_video_encoder(recording->GetOutput(), recording->videoEncoder);
399399
}
400400

401-
if (!recording->path.size() || !os_is_path_safe(recording->path.c_str())) {
401+
if (!recording->path.size()) {
402402
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
403403
}
404404

405+
if (!os_is_path_safe(recording->path.c_str())) {
406+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
407+
}
408+
405409
std::string path = recording->path;
406410

407411
char lastChar = path.back();

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,14 @@ void osn::ISimpleReplayBuffer::Start(void *data, const int64_t id, const std::ve
144144

145145
obs_output_set_video_encoder(replayBuffer->GetOutput(), videoEncoder);
146146

147-
if (!replayBuffer->path.size() || !os_is_path_safe(replayBuffer->path.c_str())) {
147+
if (!replayBuffer->path.size()) {
148148
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid recording path.");
149149
}
150150

151+
if (!os_is_path_safe(replayBuffer->path.c_str())) {
152+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Unsafe recording path: symbolic links and junctions are not allowed.");
153+
}
154+
151155
const char *rbPrefix = replayBuffer->prefix.c_str();
152156
const char *rbSuffix = replayBuffer->suffix.c_str();
153157
int64_t rbSize = replayBuffer->usesStream ? 0 : 512;

0 commit comments

Comments
 (0)