]> WPIA git - cassiopeia.git/commitdiff
fix: Check return value of writeBackFile for non-empty filename
authorBenny Baumann <BenBE@geshi.org>
Mon, 23 Feb 2015 18:33:48 +0000 (19:33 +0100)
committerBenny Baumann <BenBE@geshi.org>
Mon, 23 Feb 2015 18:33:48 +0000 (19:33 +0100)
src/apps/client.cpp
src/crypto/simpleOpensslSigner.cpp

index 7c5bf0888b5a9bb3ac6996e7e02cd1ec19ca2aa7..e30803e690ba333e6c0f828df4e9675a9a7f89ed 100644 (file)
@@ -159,8 +159,14 @@ int main( int argc, const char* argv[] ) {
                 log << "FINE: CERTIFICATE LOG: " << res->log << std::endl;
                 log << "FINE: CERTIFICATE:" << std::endl << res->certificate << std::endl;
                 std::string fn = writeBackFile( job->target.c_str(), res->certificate, keyDir );
+                if( fn.empty() ) {
+                    log << "ERROR: Writeback of the certificate failed." << std::endl;
+                    jp->failJob( job );
+                    continue;
+                }
+
                 res->crt_name = fn;
-                jp->writeBack( job, res );
+                jp->writeBack( job, res ); //! \FIXME: Check return value
                 log << "FINE: signing done." << std::endl;
 
                 if( DAEMON ) {
index dce6025fe4ebadc44ce0d7d0812d6578664ff623..f7042a29fccee7cbbdc731e5cf16e7d04469b4cd 100644 (file)
@@ -190,7 +190,13 @@ std::shared_ptr<SignedCertificate> SimpleOpensslSigner::sign( std::shared_ptr<TB
     signlog << "FINE: Signed" << std::endl;
     std::shared_ptr<SignedCertificate> output = c.sign( ca->caKey, cert->md );
     signlog << "FINE: all went well" << std::endl;
-    signlog << "FINE: crt went to: " << writeBackFile( num, output->certificate, ca->path ) << std::endl;
+    std::string fn = writeBackFile( num, output->certificate, ca->path );
+    if( fn.empty() ) {
+        signlog << "ERROR: failed to get filename for storage of signed certificate." << std::endl;
+        throw "Storage location could not be determined";
+    }
+
+    signlog << "FINE: crt went to: " << fn << std::endl;
     output->ca_name = ca->name;
     output->log = signlog.str();
     return output;