Browse Source

some security fixes

Manuel Araoz 9 years ago
parent
commit
30c0600ac1

+ 4 - 1
contracts/BadPushPayments.sol

@@ -9,7 +9,10 @@ contract BadPushPayments {
 		if (msg.value < highestBid) throw;
 		if (msg.value < highestBid) throw;
 
 
 		if (highestBidder != 0) {
 		if (highestBidder != 0) {
-			highestBidder.send(highestBid);
+      // return bid to previous winner
+			if (!highestBidder.send(highestBid)) {
+        throw;
+      }
 		}
 		}
 
 
 	  highestBidder = msg.sender;
 	  highestBidder = msg.sender;

+ 1 - 1
contracts/GoodPullPayments.sol

@@ -14,7 +14,7 @@ contract GoodPullPayments {
     highestBid = msg.value;
     highestBid = msg.value;
   }
   }
 
 
-  function withdrawRefund() external {
+  function withdrawBid() external {
     uint refund = refunds[msg.sender];
     uint refund = refunds[msg.sender];
     refunds[msg.sender] = 0;
     refunds[msg.sender] = 0;
     if (!msg.sender.send(refund)) {
     if (!msg.sender.send(refund)) {

+ 1 - 1
contracts/PullPaymentCapable.sol

@@ -1,7 +1,7 @@
 contract PullPaymentCapable {
 contract PullPaymentCapable {
   mapping(address => uint) refunds;
   mapping(address => uint) refunds;
 
 
-  function asyncSend(address dest, uint amount) {
+  function asyncSend(address dest, uint amount) internal {
     refunds[dest] += amount;
     refunds[dest] += amount;
   }
   }