Verified Commit 8ab45651 authored by shelikhoo's avatar shelikhoo
Browse files

Disallow unknown bridge list file field

parent c5e5b45b
......@@ -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
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment