fix: decode published segment fields strictly

This commit is contained in:
pingqiu committed 2026-11-19 00:30:03 -08:00
1 parent 6a2bd2a4e3
commit 2e8954aae0
1 file changed
+5
@@ -165,6 +165,11 @@ func (r *ChunkRemote) resolveManifest(ctx context.Context, h storage.ChunkHead)
if err := decodeManifestJSON(body, &doc); err != nil {
return h, err
}
decoder := json.NewDecoder(bytes.NewReader(body))
decoder.DisallowUnknownFields()
if err := decoder.Decode(&doc); err != nil {
return h, err
}
if doc.Format != 1 || doc.Range != group || doc.ChunkBytes != h.ChunkBytes || doc.Owner != ref.Owner || len(doc.Chunks) != ref.Count {
return h, errors.New("chunkstore: invalid segment contents")
}