From 890c42ec53e4743a0bc737aa32b54049184a8cfe Mon Sep 17 00:00:00 2001 From: deva Date: Mon, 10 Jan 2011 13:05:53 +0000 Subject: Fix fixed-size buffer in session reader. --- server/src/sessionserialiser.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'server/src') diff --git a/server/src/sessionserialiser.cc b/server/src/sessionserialiser.cc index 9706d22..9489bd7 100644 --- a/server/src/sessionserialiser.cc +++ b/server/src/sessionserialiser.cc @@ -33,6 +33,7 @@ #include "database.h" #include "xml_encode_decode.h" +//#include "base64.h" #include #include @@ -60,6 +61,9 @@ SessionSerialiser::SessionSerialiser(std::string path, Session *session) #define XENC(s) xml_encode(s) #define XDEC(s) xml_decode(s) +//#define BENC(s) base64encode(s) +//#define BDEC(s) base64decode(s) + void SessionSerialiser::loadStr(const std::string &xml) { // SessionAutolock lock(*session); @@ -123,9 +127,13 @@ void SessionSerialiser::load() std::string filename = getSessionFilename(path, session->id()); FILE *fp = fopen(filename.c_str(), "r"); - char xml[2048]; - memset(xml, 0, sizeof(xml)); - fread(xml, sizeof(xml), 1, fp); + std::string xml; + while(!feof(fp)) { + char str[64]; + memset(str, 0, sizeof(str)); + fread(str, sizeof(str) - 1, 1, fp); + xml += str; + } fclose(fp); loadStr(xml); -- cgit v1.2.3