diff --git a/libretroshare/src/ft/ftfilecreator.cc b/libretroshare/src/ft/ftfilecreator.cc index 292dc4729..2bd95a732 100644 --- a/libretroshare/src/ft/ftfilecreator.cc +++ b/libretroshare/src/ft/ftfilecreator.cc @@ -70,7 +70,12 @@ void ftFileCreator::closeFile() RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ if(fd != NULL) + { +#ifdef FILE_DEBUG + std::cerr << "CLOSED FILE " << (void*)fd << " (" << file_name << ")." << std::endl ; +#endif fclose(fd) ; + } fd = NULL ; } @@ -229,7 +234,7 @@ int ftFileCreator::locked_initializeFileAttrs() if (!fd) { std::cerr << "ftFileCreator::initializeFileAttrs() Failed to open (r+b): "; - std::cerr << file_name << std::endl; + std::cerr << file_name << ", errno = " << errno << std::endl; std::cerr << "ftFileCreator::initializeFileAttrs() opening w+b"; std::cerr << std::endl; @@ -239,12 +244,12 @@ int ftFileCreator::locked_initializeFileAttrs() if (!fd) { std::cerr << "ftFileCreator::initializeFileAttrs()"; - std::cerr << " Failed to open (w+b): "<< file_name << std::endl; + std::cerr << " Failed to open (w+b): "<< file_name << ", errno = " << errno << std::endl; return 0; } } #ifdef FILE_DEBUG - std::cerr << "ftFileCreator::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl; + std::cerr << "OPENNED FILE " << (void*)fd << " (" << file_name << "), for r/w." << std::endl ; #endif return 1; diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index 4bdc1495e..c366f1c5c 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -273,8 +273,12 @@ bool p3ConfigMgr::backedUpFileSave(const std::string& fname, const std::string& return true; } - fwrite(config_buff,1, size_file, file); - fwrite(sign_buff, 1, size_sign, sign); + if(size_file != fwrite(config_buff,1, size_file, file)) + getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + fname_backup + "\nIs your disc full or out of quota ?"); + + if(size_sign != fwrite(sign_buff, 1, size_sign, sign)) + getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing main signature file " + sign_fname_backup + "\nIs your disc full or out of quota ?"); + fclose(file); fclose(sign); @@ -751,7 +755,8 @@ bool p3Config::backedUpFileSave(const std::string& cfg_fname, const std::string& written &= false; // at least one file save should be successful } - if(size_file > 0){ + if(size_file > 0) + { // now write actual back-up file cfg_file = fopen(cfg_fname_backup.c_str(), "wb"); @@ -762,7 +767,9 @@ bool p3Config::backedUpFileSave(const std::string& cfg_fname, const std::string& #endif } - fwrite(buff, 1, size_file, cfg_file); + if(size_file != fwrite(buff, 1, size_file, cfg_file)) + getPqiNotify()->AddSysMessage(0, RS_SYS_WARNING, "Write error", "Error while writing backup configuration file " + cfg_fname_backup + "\nIs your disc full or out of quota ?"); + fclose(cfg_file); #ifdef CONFIG_DEBUG diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index 80d35fb3a..893671901 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -3474,7 +3474,7 @@ void peerConnectState::updateIpAddressList(const IpAddressTimed& ipTimed) return ; } - if(ipTimed.ipAddr.sin_addr.s_addr == 0 || ipTimed.ipAddr.sin_port == 0) + if(ipTimed.ipAddr.sin_addr.s_addr == 0 || ipTimed.ipAddr.sin_addr.s_addr == 1 || ipTimed.ipAddr.sin_port == 0) { #ifdef CONN_DEBUG std::cerr << "peerConnectState::updateIpAdressList() ip parameter is 0.0.0.0, or port is 0, ignoring." << std::endl; diff --git a/libretroshare/src/pqi/pqistore.cc b/libretroshare/src/pqi/pqistore.cc index ce73f04ac..5c020a783 100644 --- a/libretroshare/src/pqi/pqistore.cc +++ b/libretroshare/src/pqi/pqistore.cc @@ -331,6 +331,10 @@ int pqistore::readPkt(RsItem **item_out) // workout how much more to read. int extralen = getRsItemSize(block) - blen; + + if(extralen+blen > maxlen) + std::cerr << "***** ERROR: trying to read a packet of length " << extralen+blen << ", while the maximum length is " << maxlen << std::endl ; + if (extralen > 0) { if(extralen > blen + maxlen)