Skip to content

Commit

Permalink
fix: Ensures that the parsed value is within the bounds of int32
Browse files Browse the repository at this point in the history
Fix code scanning alert no. 2: Incorrect conversion between integer types

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Bruce Huang <weichou1229@gmail.com>
  • Loading branch information
1 parent 124a5f1 commit 22d23d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/driver/subscriptionrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ func newSubscriptionRequest(attributes map[string]interface{}, requestData []byt

messageLimit, ok := attributes[DefaultMessageLimit]
if request.MessageLimit == nil && ok {
val, err := strconv.Atoi(fmt.Sprint(messageLimit))
val64, err := strconv.ParseInt(fmt.Sprint(messageLimit), 10, 32)
if err != nil {
return nil, errors.NewCommonEdgeX(errors.KindServerError, fmt.Sprintf("failed to parse the request attribute '%s'", DefaultMessageLimit), err)
}
val := int(val64)
request.MessageLimit = &val
}
return request, nil
Expand Down

0 comments on commit 22d23d7

Please sign in to comment.