Skip to content

Commit

Permalink
Fix potential array out of bounds in the runtime (#437)
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent caafc0a commit 1ed5256
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Add models to Modus AssemblyScript SDK [#428](https://github.com/hypermodeinc/modus/pull/428)
- Update Readme files [#432](https://github.com/hypermodeinc/modus/pull/432)
- Fix vulnerability in AssemblyScript SDK install script [#435](https://github.com/hypermodeinc/modus/pull/435)
- Fix potential array out of bounds in the runtime [#437](https://github.com/hypermodeinc/modus/pull/437)

## 2024-10-02 - Version 0.12.7

Expand Down
11 changes: 10 additions & 1 deletion runtime/languages/golang/typeinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package golang
import (
"context"
"fmt"
"math"
"reflect"
"strconv"
"strings"
Expand Down Expand Up @@ -117,7 +118,15 @@ func (lti *langTypeInfo) ArrayLength(typ string) (int, error) {
return -1, fmt.Errorf("invalid array type: %s", typ)
}

return strconv.Atoi(size)
parsedSize, err := strconv.Atoi(size)
if err != nil {
return -1, err
}
if parsedSize < 0 || parsedSize > math.MaxUint32 {
return -1, fmt.Errorf("array size out of bounds: %s", size)
}

return parsedSize, nil
}

func (lti *langTypeInfo) IsBooleanType(typ string) bool {
Expand Down

0 comments on commit 1ed5256

Please sign in to comment.