mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
check by using fopen if f is valid, because started in /usr/local/bin without admin don't allow fopen in same dir as binary and leads to Segmentation fault error and crash
This commit is contained in:
parent
939e942ba8
commit
53d1309517
@ -64,8 +64,10 @@ int Mnemonic::init(void(*fill_words_func)(unsigned char*), unsigned int original
|
||||
uncompressed_file_name += std::to_string(original_size);
|
||||
uncompressed_file_name += ".txt";
|
||||
FILE* f = fopen(uncompressed_file_name.data(), "w");
|
||||
fwrite(uncompressed_buffer, sizeof(char), original_size, f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
fwrite(uncompressed_buffer, sizeof(char), original_size, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
unsigned short cursor = 0;
|
||||
u32 word_begin = 0, word_end = 0;
|
||||
@ -335,9 +337,11 @@ void Mnemonic::printToFile(const char* filename)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> _lock(mWorkingMutex);
|
||||
FILE* f = fopen(filename, "wt");
|
||||
auto words = getCompleteWordListSorted();
|
||||
fwrite(words.data(), 1, words.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
auto words = getCompleteWordListSorted();
|
||||
fwrite(words.data(), 1, words.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
Poco::JSON::Array Mnemonic::getSortedWordList()
|
||||
|
||||
@ -73,9 +73,11 @@ Poco::Dynamic::Var JsonRequestHandler::parseJsonWithErrorPrintFile(std::istream&
|
||||
std::string dateTimeString = Poco::DateTimeFormatter::format(Poco::DateTime(), "%d_%m_%yT%H_%M_%S");
|
||||
std::string filename = dateTimeString + "_response.html";
|
||||
FILE* f = fopen(filename.data(), "wt");
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
return Poco::Dynamic::Var();
|
||||
}
|
||||
return Poco::Dynamic::Var();
|
||||
|
||||
@ -70,9 +70,11 @@ JsonRequestReturn JsonRequest::request(const char* methodName, const Poco::Net::
|
||||
fileName += ".html";
|
||||
|
||||
FILE* f = fopen(fileName.data(), "wt");
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
// */
|
||||
sendErrorsAsEmail(responseStringStream.str());
|
||||
return JSON_REQUEST_RETURN_PARSE_ERROR;
|
||||
|
||||
@ -220,9 +220,11 @@ int SigningTransaction::run() {
|
||||
addError(new ParamError("SigningTransaction", "error parsing request answer", ex.displayText().data()));
|
||||
|
||||
FILE* f = fopen("response.html", "wt");
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
if (f) {
|
||||
std::string responseString = responseStringStream.str();
|
||||
fwrite(responseString.data(), 1, responseString.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
// */
|
||||
sendErrorsAsEmail(responseStringStream.str());
|
||||
return -9;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user