github-code-scanning[bot] commented on code in PR #7032:
URL: https://github.com/apache/trafficcontrol/pull/7032#discussion_r952010243


##########
lib/go-atscfg/atscfg.go:
##########
@@ -226,21 +226,21 @@
        return "# " + hdrComment + "\n\n"
 }
 
-// getATSMajorVersionFromATSVersion returns the major version of the given 
profile's package trafficserver parameter.
+// GetATSMajorVersionFromATSVersion returns the major version of the given 
profile's package trafficserver parameter.
 // The atsVersion is typically a Parameter on the Server's Profile, with the 
configFile "package" name "trafficserver".
 // Returns an error if atsVersion is empty or does not start with an unsigned 
integer followed by a period or nothing.
-func getATSMajorVersionFromATSVersion(atsVersion string) (int, error) {
+func GetATSMajorVersionFromATSVersion(atsVersion string) (uint, error) {
        dotPos := strings.Index(atsVersion, ".")
        if dotPos == -1 {
                dotPos = len(atsVersion) // if there's no '.' then assume the 
whole string is just a major version.
        }
        majorVerStr := atsVersion[:dotPos]
 
-       majorVer, err := strconv.Atoi(majorVerStr)
-       if err != nil || majorVer < 0 {
+       majorVer, err := strconv.ParseUint(majorVerStr, 10, 64)
+       if err != nil || majorVer == 0 {
                return 0, errors.New("unexpected version format '" + 
majorVerStr + "', expected e.g. '7.1.2.whatever'")
        }
-       return majorVer, nil
+       return uint(majorVer), nil

Review Comment:
   ## Incorrect conversion between integer types
   
   Incorrect conversion of a 64-bit integer from [strconv.ParseUint](1) to a 
lower bit size type uint without an upper bound check.
   
   [Show more 
details](https://github.com/apache/trafficcontrol/security/code-scanning/220)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to