Skip to content

Commit

Permalink
fix: visibilityInt value check (#1429)
Browse files Browse the repository at this point in the history
  • Loading branch information
constwz authored Jul 5, 2024
1 parent c7a88d1 commit d939fcf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modular/gater/object_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1166,6 +1166,10 @@ func (g *GateModular) delegatePutObjectHandler(w http.ResponseWriter, r *http.Re
if err != nil {
return
}
if visibilityInt < 0 || visibilityInt >= int64(len(storagetypes.VisibilityType_value)) {
err = ErrInvalidQuery
return
}
visibility = storagetypes.VisibilityType(visibilityInt)
if visibility == storagetypes.VISIBILITY_TYPE_UNSPECIFIED {
visibility = storagetypes.VISIBILITY_TYPE_INHERIT // set default visibility type
Expand Down Expand Up @@ -1391,6 +1395,10 @@ func (g *GateModular) delegateResumablePutObjectHandler(w http.ResponseWriter, r
if err != nil {
return
}
if visibilityInt < 0 || visibilityInt >= int64(len(storagetypes.VisibilityType_value)) {
err = ErrInvalidQuery
return
}
visibility = storagetypes.VisibilityType(visibilityInt)
if visibility == storagetypes.VISIBILITY_TYPE_UNSPECIFIED {
visibility = storagetypes.VISIBILITY_TYPE_INHERIT // set default visibility type
Expand Down Expand Up @@ -1617,6 +1625,10 @@ func (g *GateModular) delegateCreateFolderHandler(w http.ResponseWriter, r *http
if err != nil {
return
}
if visibilityInt < 0 || visibilityInt >= int64(len(storagetypes.VisibilityType_value)) {
err = ErrInvalidQuery
return
}
visibility = storagetypes.VisibilityType(visibilityInt)
if visibility == storagetypes.VISIBILITY_TYPE_UNSPECIFIED {
visibility = storagetypes.VISIBILITY_TYPE_INHERIT // set default visibility type
Expand Down

0 comments on commit d939fcf

Please sign in to comment.