This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f2691f  Fix codeql t3c false positives (#5923)
3f2691f is described below

commit 3f2691f34651334c1b181114dd4eb1de1cb9e784
Author: Robert O Butts <[email protected]>
AuthorDate: Tue Jun 8 12:12:21 2021 -0600

    Fix codeql t3c false positives (#5923)
---
 lib/go-atscfg/atscfg.go          |  6 +++---
 lib/go-atscfg/parentdotconfig.go | 20 ++++++++------------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/go-atscfg/atscfg.go b/lib/go-atscfg/atscfg.go
index d424d4c..c35a1e9 100644
--- a/lib/go-atscfg/atscfg.go
+++ b/lib/go-atscfg/atscfg.go
@@ -205,11 +205,11 @@ func getATSMajorVersionFromATSVersion(atsVersion string) 
(int, error) {
        }
        majorVerStr := atsVersion[:dotPos]
 
-       majorVer, err := strconv.ParseUint(majorVerStr, 10, 64)
-       if err != nil {
+       majorVer, err := strconv.Atoi(majorVerStr)
+       if err != nil || majorVer < 0 {
                return 0, errors.New("unexpected version format '" + 
majorVerStr + "', expected e.g. '7.1.2.whatever'")
        }
-       return int(majorVer), nil
+       return majorVer, nil
 }
 
 // genericProfileConfig generates a generic profile config text, from the 
profile's parameters with the given config file name.
diff --git a/lib/go-atscfg/parentdotconfig.go b/lib/go-atscfg/parentdotconfig.go
index 1a161ff..c24f795 100644
--- a/lib/go-atscfg/parentdotconfig.go
+++ b/lib/go-atscfg/parentdotconfig.go
@@ -928,20 +928,18 @@ func serverParentageParams(sv *Server, params 
[]parameterWithProfilesMap) (profi
                case ParentConfigCacheParamWeight:
                        profileCache.Weight = param.Value
                case ParentConfigCacheParamPort:
-                       i, err := strconv.ParseInt(param.Value, 10, 64)
-                       if err != nil {
+                       if i, err := strconv.Atoi(param.Value); err != nil {
                                warnings = append(warnings, "port param is not 
an integer, skipping! : "+err.Error())
                        } else {
-                               profileCache.Port = int(i)
+                               profileCache.Port = i
                        }
                case ParentConfigCacheParamUseIP:
                        profileCache.UseIP = param.Value == "1"
                case ParentConfigCacheParamRank:
-                       i, err := strconv.ParseInt(param.Value, 10, 64)
-                       if err != nil {
+                       if i, err := strconv.Atoi(param.Value); err != nil {
                                warnings = append(warnings, "rank param is not 
an integer, skipping! : "+err.Error())
                        } else {
-                               profileCache.Rank = int(i)
+                               profileCache.Rank = i
                        }
                case ParentConfigCacheParamNotAParent:
                        profileCache.NotAParent = param.Value != "false"
@@ -1449,20 +1447,18 @@ func getParentConfigProfileParams(
                                // TODO validate float?
                                profileCache.Weight = val
                        case ParentConfigCacheParamPort:
-                               i, err := strconv.ParseInt(val, 10, 64)
-                               if err != nil {
+                               if i, err := strconv.Atoi(val); err != nil {
                                        warnings = append(warnings, "port param 
is not an integer, skipping! : "+err.Error())
                                } else {
-                                       profileCache.Port = int(i)
+                                       profileCache.Port = i
                                }
                        case ParentConfigCacheParamUseIP:
                                profileCache.UseIP = val == "1"
                        case ParentConfigCacheParamRank:
-                               i, err := strconv.ParseInt(val, 10, 64)
-                               if err != nil {
+                               if i, err := strconv.Atoi(val); err != nil {
                                        warnings = append(warnings, "rank param 
is not an integer, skipping! : "+err.Error())
                                } else {
-                                       profileCache.Rank = int(i)
+                                       profileCache.Rank = i
                                }
                        case ParentConfigCacheParamNotAParent:
                                profileCache.NotAParent = val != "false"

Reply via email to