From: Carl Hetherington Date: Tue, 6 Oct 2020 09:26:14 +0000 (+0200) Subject: Missing error checking on writing KDMs as XML. X-Git-Tag: v1.8.0~261 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=b4e1d9fffeb3a834e30ec13bbd467cecd88f87f9;p=libdcp.git Missing error checking on writing KDMs as XML. --- diff --git a/src/encrypted_kdm.cc b/src/encrypted_kdm.cc index 071bf870..e8e89870 100644 --- a/src/encrypted_kdm.cc +++ b/src/encrypted_kdm.cc @@ -707,9 +707,15 @@ void EncryptedKDM::as_xml (boost::filesystem::path path) const { FILE* f = fopen_boost (path, "w"); + if (!f) { + throw FileError ("Could not open KDM file for writing", path, errno); + } string const x = as_xml (); - fwrite (x.c_str(), 1, x.length(), f); + size_t const written = fwrite (x.c_str(), 1, x.length(), f); fclose (f); + if (written != x.length()) { + throw FileError ("Could not write to KDM file", path, errno); + } } string