diff --git a/lib/config.cpp b/lib/config.cpp index 99b1503a..c974c3ac 100644 --- a/lib/config.cpp +++ b/lib/config.cpp @@ -341,5 +341,9 @@ void Util::Daemonize(){ #if DEBUG >= 3 fprintf(stderr, "Going into background mode...\n"); #endif - daemon(1, 0); + if (daemon(1, 0) < 0) { + #if DEBUG >= 1 + fprintf(stderr, "Failed to daemonize: %s\n", strerror(errno)); + #endif + } } diff --git a/lib/dtsc.cpp b/lib/dtsc.cpp index e18d7817..44f00ebe 100644 --- a/lib/dtsc.cpp +++ b/lib/dtsc.cpp @@ -228,7 +228,12 @@ DTSC::File::File(std::string filename, bool create){ std::string & DTSC::File::getHeader(){ fseek(F, 8, SEEK_SET); strbuffer.resize(headerSize); - fread((void*)strbuffer.c_str(), headerSize, 1, F); + if (fread((void*)strbuffer.c_str(), headerSize, 1, F) != headerSize){ + /// \todo check seek as well and do something more sensible... + #if DEBUG >= 10 + fprintf(stderr, "Panic! Invalid DTSC File header\n"); + #endif + } fseek(F, 8+headerSize, SEEK_SET); return strbuffer; }