summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-06 11:26:14 +0200
committerCarl Hetherington <cth@carlh.net>2020-10-06 11:26:14 +0200
commitb4e1d9fffeb3a834e30ec13bbd467cecd88f87f9 (patch)
treeef7cc539bffc3199fe587e26664c9c4ab76e39a2
parent3938e58e689ae092ab0565b894c7d88831f26a85 (diff)
Missing error checking on writing KDMs as XML.
-rw-r--r--src/encrypted_kdm.cc8
1 files changed, 7 insertions, 1 deletions
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