Potential fix for code scanning alert no. 6: Slice memory allocation with excessive size value

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
samandCopilot Autofix powered by AI authored and GitHub committed 2026-09-03 15:13:35 +10:00
1 parent febc9f075a
commit 50b41e32e0
2 files changed
+32 -2

No files matched your search

+16 -1
View File
@@ -32,7 +32,22 @@ func (s *Server) handleLogs(w http.ResponseWriter, r *http.Request) {
}
q := r.URL.Query()
limit, _ := strconv.Atoi(q.Get("limit"))
limit := logging.DefaultTailLines
if raw := strings.TrimSpace(q.Get("limit")); raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
http.Error(w, "bad limit", http.StatusBadRequest)
return
}
switch {
case parsed <= 0:
limit = logging.DefaultTailLines
case parsed > logging.MaxTailLines:
limit = logging.MaxTailLines
default:
limit = parsed
}
}
result, err := logging.Tail(path, logging.Query{
Levels: splitCSV(q.Get("level")),
Component: strings.TrimSpace(q.Get("component")),
+16 -1
View File
@@ -56,7 +56,22 @@ func (s *Server) handleTaskLogs(w http.ResponseWriter, r *http.Request) {
return
}
limit, _ := strconv.Atoi(q.Get("limit"))
limit := logging.DefaultTailLines
if raw := strings.TrimSpace(q.Get("limit")); raw != "" {
parsed, err := strconv.Atoi(raw)
if err != nil {
http.Error(w, "bad limit", http.StatusBadRequest)
return
}
switch {
case parsed <= 0:
limit = logging.DefaultTailLines
case parsed > logging.MaxTailLines:
limit = logging.MaxTailLines
default:
limit = parsed
}
}
result, err := logging.Tail(path, logging.Query{
Levels: splitCSV(q.Get("level")),
Component: strings.TrimSpace(q.Get("component")),