Explorar o código

ftp, sftp: Fix heap-after-free bug on exception

Tatsuhiro Tsujikawa %!s(int64=10) %!d(string=hai) anos
pai
achega
bb8df11d7e
Modificáronse 2 ficheiros con 2 adicións e 2 borrados
  1. 1 1
      src/FtpNegotiationCommand.cc
  2. 1 1
      src/SftpNegotiationCommand.cc

+ 1 - 1
src/FtpNegotiationCommand.cc

@@ -467,12 +467,12 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
       poolConnection();
       poolConnection();
       return false;
       return false;
     }
     }
-    checkIntegrityEntry->pushNextCommand(std::unique_ptr<Command>(this));
     // We have to make sure that command that has Request object must
     // We have to make sure that command that has Request object must
     // have segment after PieceStorage is initialized. See
     // have segment after PieceStorage is initialized. See
     // AbstractCommand::execute()
     // AbstractCommand::execute()
     getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
     getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
 
 
+    checkIntegrityEntry->pushNextCommand(std::unique_ptr<Command>(this));
     prepareForNextAction(std::move(checkIntegrityEntry));
     prepareForNextAction(std::move(checkIntegrityEntry));
 
 
     disableReadCheckSocket();
     disableReadCheckSocket();

+ 1 - 1
src/SftpNegotiationCommand.cc

@@ -299,12 +299,12 @@ void SftpNegotiationCommand::onFileSizeDetermined(int64_t totalLength)
       poolConnection();
       poolConnection();
       return;
       return;
     }
     }
-    checkIntegrityEntry->pushNextCommand(std::unique_ptr<Command>(this));
     // We have to make sure that command that has Request object must
     // We have to make sure that command that has Request object must
     // have segment after PieceStorage is initialized. See
     // have segment after PieceStorage is initialized. See
     // AbstractCommand::execute()
     // AbstractCommand::execute()
     getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
     getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
 
 
+    checkIntegrityEntry->pushNextCommand(std::unique_ptr<Command>(this));
     prepareForNextAction(std::move(checkIntegrityEntry));
     prepareForNextAction(std::move(checkIntegrityEntry));
 
 
     disableReadCheckSocket();
     disableReadCheckSocket();