From 59378ae7fe3d7293a92f44eaa2316a6d99d4ee1b Mon Sep 17 00:00:00 2001 From: Johannes Bornhold Date: Tue, 11 Apr 2017 21:16:47 +0200 Subject: [PATCH] Read config into memory and pass its content to tinyxml2 (#253) tinyxml2 does not support to read from a named pipe, since it uses seek to figure out the file size. In the case of a pipe this is not possible. Reading the file content into memory and passing the content to tinyxml2 allows to mitigate this problem. --- encfs/XmlReader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/encfs/XmlReader.cpp b/encfs/XmlReader.cpp index c0aaf9b..285a7ef 100644 --- a/encfs/XmlReader.cpp +++ b/encfs/XmlReader.cpp @@ -23,6 +23,8 @@ #include // for remove_if #include // for NULL #include // for shared_ptr +#include // for ifstream +#include // for ostringstream #include // for XMLElement, XMLNode, XMLDocument (ptr only) @@ -167,7 +169,12 @@ XmlReader::~XmlReader() {} bool XmlReader::load(const char *fileName) { pd->doc.reset(new tinyxml2::XMLDocument()); - auto err = pd->doc->LoadFile(fileName); + std::ifstream in(fileName); + if (!in) return false; + + std::ostringstream fileContent; + fileContent << in.rdbuf(); + auto err = pd->doc->Parse(fileContent.str().c_str()); return err == tinyxml2::XML_SUCCESS; }