do not ignore return value of write()

JSON-15
Roker 7 years ago
parent 0430d3a703
commit abe9c5deab

@ -1,7 +1,7 @@
BUILD_ON=$(shell uname)
BUILD_FOR=$(BUILD_ON)
CXX = c++ -std=c++11 -Wall -O0 -g -fstack-protector-all
CXX = c++ -std=c++11 -Wall -O3 -g -fstack-protector-all
ifeq ($(BUILD_ON),Darwin)
ifeq ($(BUILD_FOR),Darwin)

@ -24,7 +24,7 @@ enum class JSON_RPC
js::Object call(const FunctionMap& fm, const js::Object& request, Context* context);
// create a JSON-RPC 2.0 compatible result response object
js::Object make_result(const js::Value& result, int id);
//js::Object make_result(const js::Value& result, int id);
// create a JSON-RPC 2.0 compatible error response object
js::Object make_error(JSON_RPC error_code, const std::string& error_message, const js::Value& data, int id);

@ -65,7 +65,11 @@ std::string create_security_token(const std::string& server_address, unsigned po
o.emplace_back("security_token", sec_token );
const std::string content = js::write( o, js::pretty_print | js::raw_utf8 ) + '\n';
write(fd, content.data(), content.size());
const ssize_t ss = write(fd, content.data(), content.size());
if(ss<0 || uint64_t(ss)!=content.size())
{
throw std::runtime_error("Cannot write into security token file \"" + filename + "\": " + std::to_string(errno));
}
close(fd);
return sec_token;

Loading…
Cancel
Save