diff options
| -rw-r--r-- | src/encrypted_kdm.cc | 13 | ||||
| -rw-r--r-- | src/exceptions.cc | 6 | ||||
| -rw-r--r-- | src/exceptions.h | 6 |
3 files changed, 21 insertions, 4 deletions
diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index b6a992fb..054162cc 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2017 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -34,6 +34,7 @@ #include "encrypted_kdm.h" #include "util.h" #include "certificate_chain.h" +#include "exceptions.h" #include <libcxml/cxml.h> #include <libxml++/document.h> #include <libxml++/nodes/element.h> @@ -525,9 +526,13 @@ public: EncryptedKDM::EncryptedKDM (string s) { - shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage")); - doc->read_string (s); - _data = new data::EncryptedKDMData (doc); + try { + shared_ptr<cxml::Document> doc (new cxml::Document ("DCinemaSecurityMessage")); + doc->read_string (s); + _data = new data::EncryptedKDMData (doc); + } catch (xmlpp::parse_error& e) { + throw KDMFormatError (e.what ()); + } } EncryptedKDM::EncryptedKDM ( diff --git a/src/exceptions.cc b/src/exceptions.cc index b541beda..fbd8c85f 100644 --- a/src/exceptions.cc +++ b/src/exceptions.cc @@ -96,3 +96,9 @@ KDMDecryptionError::KDMDecryptionError (std::string message) { } + +KDMFormatError::KDMFormatError (std::string message) + : runtime_error (String::compose ("Could not parse KDM (%1)", message)) +{ + +} diff --git a/src/exceptions.h b/src/exceptions.h index 2688ee86..ed77ae3a 100644 --- a/src/exceptions.h +++ b/src/exceptions.h @@ -179,6 +179,12 @@ public: KDMDecryptionError (std::string message); }; +class KDMFormatError : public std::runtime_error +{ +public: + KDMFormatError (std::string message); +}; + } #endif |
