mirror of https://github.com/ceph/go-ceph
rbd: trigger an error on invalid max snaps value
In file include from rbd.go:931 var cMaxSnaps C.int ret := C.rbd_snap_list(image.image, nil, &cMaxSnaps) cSnaps := make([]C.rbd_snap_info_t, cMaxSnaps) It is necessary to determine whether cMaxSnaps is a large 0. Otherwise, the following code will panic ret = C.rbd_snap_list(image.image,&cSnaps[0], &cMaxSnaps) Signed-off-by: zxysilent <zxysilent@outlook.com>
This commit is contained in:
parent
cfae965d25
commit
2146f1af0c
|
@ -936,7 +936,10 @@ func (image *Image) GetSnapshotNames() (snaps []SnapInfo, err error) {
|
||||||
var cMaxSnaps C.int
|
var cMaxSnaps C.int
|
||||||
|
|
||||||
ret := C.rbd_snap_list(image.image, nil, &cMaxSnaps)
|
ret := C.rbd_snap_list(image.image, nil, &cMaxSnaps)
|
||||||
|
// bugfix index out of range(&cSnaps[0])
|
||||||
|
if cMaxSnaps < 1 {
|
||||||
|
return nil, rbdError(ret)
|
||||||
|
}
|
||||||
cSnaps := make([]C.rbd_snap_info_t, cMaxSnaps)
|
cSnaps := make([]C.rbd_snap_info_t, cMaxSnaps)
|
||||||
snaps = make([]SnapInfo, cMaxSnaps)
|
snaps = make([]SnapInfo, cMaxSnaps)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue