Преглед изворни кода

Fix: don't panic on "null" values in OSL JSON config

Rod Hynes пре 4 година
родитељ
комит
280bf05f78
1 измењених фајлова са 9 додато и 0 уклоњено
  1. 9 0
      psiphon/common/osl/osl.go

+ 9 - 0
psiphon/common/osl/osl.go

@@ -294,6 +294,10 @@ func LoadConfig(configJSON []byte) (*Config, error) {
 
 	for _, scheme := range config.Schemes {
 
+		if scheme == nil {
+			return nil, errors.TraceNew("invalid scheme")
+		}
+
 		epoch, err := time.Parse(time.RFC3339, scheme.Epoch)
 		if err != nil {
 			return nil, errors.Tracef("invalid epoch format: %s", err)
@@ -322,6 +326,11 @@ func LoadConfig(configJSON []byte) (*Config, error) {
 		}
 
 		for index, seedSpec := range scheme.SeedSpecs {
+
+			if seedSpec == nil {
+				return nil, errors.TraceNew("invalid seed spec")
+			}
+
 			if len(seedSpec.ID) != KEY_LENGTH_BYTES {
 				return nil, errors.TraceNew("invalid seed spec ID")
 			}