소스 검색

Fix AtomicPut panic if previous KVPair is not nil and key not exists in boltdb

Signed-off-by: Chun Chen <ramichen@tencent.com>
Chun Chen 9 년 전
부모
커밋
1f9cf17713
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      libnetwork/internal/kvstore/boltdb/boltdb.go

+ 3 - 0
libnetwork/internal/kvstore/boltdb/boltdb.go

@@ -257,6 +257,9 @@ func (b *BoltDB) AtomicPut(key string, value []byte, previous *store.KVPair, opt
 			return store.ErrKeyModified
 		}
 		if previous != nil {
+			if len(val) == 0 {
+				return store.ErrKeyNotFound
+			}
 			dbIndex = binary.LittleEndian.Uint64(val[:libkvmetadatalen])
 			if dbIndex != previous.LastIndex {
 				return store.ErrKeyModified