ソースを参照

cmd/stunstamp: fix handling of invalid DERP map resp (#12679)

Updates tailscale/corp#20344

Signed-off-by: Jordan Whited <[email protected]>
Jordan Whited 1 年間 前
コミット
ddf94a7b39
1 ファイル変更4 行追加1 行削除
  1. 4 1
      cmd/stunstamp/stunstamp.go

+ 4 - 1
cmd/stunstamp/stunstamp.go

@@ -60,10 +60,13 @@ func getDERPMap(ctx context.Context, url string) (*tailcfg.DERPMap, error) {
 		return nil, err
 	}
 	defer resp.Body.Close()
+	if resp.StatusCode != 200 {
+		return nil, fmt.Errorf("non-200 derp map resp: %d", resp.StatusCode)
+	}
 	dm := tailcfg.DERPMap{}
 	err = json.NewDecoder(resp.Body).Decode(&dm)
 	if err != nil {
-		return nil, nil
+		return nil, fmt.Errorf("failed to decode derp map resp: %v", err)
 	}
 	return &dm, nil
 }