diff options
author | deva <deva> | 2011-01-10 13:05:53 +0000 |
---|---|---|
committer | deva <deva> | 2011-01-10 13:05:53 +0000 |
commit | 890c42ec53e4743a0bc737aa32b54049184a8cfe (patch) | |
tree | 0dbc0f33c22ee1c22f0ce4d006a118fe6bc384de | |
parent | bc428bdfdf15389535273a05c1fadb90e2bb066c (diff) |
Fix fixed-size buffer in session reader.
-rw-r--r-- | server/src/sessionserialiser.cc | 14 |
1 files changed, 11 insertions, 3 deletions
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 <stdio.h> #include <string.h> @@ -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); |