This is an automated email from the git hooks/post-receive script.
shelikhoo pushed a commit to branch main in repository pluggable-transports/snowflake.
commit 8ab45651d094de98ff48c5900e6de50a74a0f867 Author: Shelikhoo xiaokangwang@outlook.com AuthorDate: Wed May 18 12:19:21 2022 +0100
Disallow unknown bridge list file field --- broker/bridge-list.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/broker/bridge-list.go b/broker/bridge-list.go index ca2c041..8a80f6a 100644 --- a/broker/bridge-list.go +++ b/broker/bridge-list.go @@ -2,11 +2,13 @@ package main
import ( "bufio" + "bytes" "encoding/json" "errors" - "git.torproject.org/pluggable-transports/snowflake.git/v2/common/bridgefingerprint" "io" "sync" + + "git.torproject.org/pluggable-transports/snowflake.git/v2/common/bridgefingerprint" )
var ErrBridgeNotFound = errors.New("bridge not found") @@ -50,7 +52,9 @@ func (h *bridgeListHolder) LoadBridgeInfo(reader io.Reader) error { for inputScanner.Scan() { inputLine := inputScanner.Bytes() bridgeInfo := BridgeInfo{} - if err := json.Unmarshal(inputLine, &bridgeInfo); err != nil { + decoder := json.NewDecoder(bytes.NewReader(inputLine)) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&bridgeInfo); err != nil { return err }