summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-04-05 23:16:58 +0200
committerCarl Hetherington <cth@carlh.net>2020-04-05 23:16:58 +0200
commitca857726de26996b94b0a26fa1bf4cde1a897877 (patch)
tree15ba10ff5f8a04a3464606d5e2bd986f87892054
parentb155c15a88e51147d85f0328ff4b96a87dac4fda (diff)
Add some basic sanity checking to the writer.
-rw-r--r--src/tools/dcpomatic_disk_writer.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc
index 8618f64a0..a896cd181 100644
--- a/src/tools/dcpomatic_disk_writer.cc
+++ b/src/tools/dcpomatic_disk_writer.cc
@@ -67,6 +67,7 @@ extern "C" {
#include <unistd.h>
#include <sys/types.h>
#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
#include <iostream>
using std::cin;
@@ -377,6 +378,8 @@ polkit_callback (GObject *, GAsyncResult* res, gpointer)
bool
idle ()
{
+ using namespace boost::algorithm;
+
optional<string> s = nanomsg->nonblocking_get ();
if (!s) {
return true;
@@ -388,6 +391,26 @@ idle ()
dcp_path = nanomsg->blocking_get();
device = nanomsg->blocking_get();
+ /* Do some basic sanity checks */
+#ifdef DCPOMATIC_OSX
+ if (!starts_with(device, "/dev/disk")) {
+ LOG_DISK ("Will not write to %1", device);
+ return;
+ }
+#endif
+#ifdef DCPOMATIC_LINUX
+ if (!starts_with(device, "/dev/sd") && !starts_with(device, "/dev/hd")) {
+ LOG_DISK ("Will not write to %1", device);
+ return true;
+ }
+#endif
+#ifdef DCPOMATIC_WINDOWS
+ if (!starts_with(device, "\\\\.\\PHYSICALDRIVE")) {
+ LOG_DISK ("Will not write to %1", device);
+ return true;
+ }
+#endif
+
LOG_DISK ("Here we go writing %1 to %2", dcp_path, device);
#ifdef DCPOMATIC_LINUX