Procházet zdrojové kódy

Guard against potential nil pointer dereference

Rod Hynes před 5 roky
rodič
revize
323bd2c00a
1 změnil soubory, kde provedl 10 přidání a 9 odebrání
  1. 10 9
      psiphon/server/replay.go

+ 10 - 9
psiphon/server/replay.go

@@ -64,6 +64,14 @@ type replayCacheMetrics struct {
 	DeleteReplayCount  int64
 }
 
+type replayParameters struct {
+	replayPacketManipulation   bool
+	packetManipulationSpecName string
+	replayFragmentor           bool
+	fragmentorSeed             *prng.Seed
+	failedCount                int
+}
+
 // NewReplayCache creates a new ReplayCache.
 func NewReplayCache(support *SupportServices) *ReplayCache {
 	return &ReplayCache{
@@ -326,7 +334,8 @@ func (r *ReplayCache) FailedReplayParameters(
 	if (parameters.replayPacketManipulation &&
 		parameters.packetManipulationSpecName != packetManipulationSpecName) ||
 		(parameters.replayFragmentor &&
-			*parameters.fragmentorSeed != *fragmentorSeed) {
+			(fragmentorSeed == nil ||
+				*parameters.fragmentorSeed != *fragmentorSeed)) {
 		return
 	}
 
@@ -350,11 +359,3 @@ func (r *ReplayCache) makeKey(
 		"%s-%s-%s",
 		tunnelProtocol, geoIPData.Country, geoIPData.ISP)
 }
-
-type replayParameters struct {
-	replayPacketManipulation   bool
-	packetManipulationSpecName string
-	replayFragmentor           bool
-	fragmentorSeed             *prng.Seed
-	failedCount                int
-}