Skip to content

Commit

Permalink
Merge pull request Qitmeer#704 from dindinw/main
Browse files Browse the repository at this point in the history
core/shutdown/tracker: fix security alert for size computation for al…
  • Loading branch information
dindinw authored May 22, 2024
2 parents 4c19807 + d6e81ca commit 4d595ec
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
Expand All @@ -43,7 +43,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -68,4 +68,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v3
7 changes: 5 additions & 2 deletions core/shutdown/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package shutdown

import (
"fmt"
"io/ioutil"
"os"
"path"
)
Expand All @@ -24,6 +23,10 @@ func (t *Tracker) Check() error {
if len(bhbs) <= 0 {
return nil
}
max_file_size := 512
if len(bhbs) > max_file_size*1024 { // 512 kb
return fmt.Errorf("file size large than %d kb : %s", max_file_size, t.filePath)
}
err = fmt.Errorf("Illegal withdrawal at block:%s, you can cleanup your block data base by '--cleanup'.", string(bhbs))
log.Error(err.Error())
return err
Expand Down Expand Up @@ -72,7 +75,7 @@ func ReadFile(path string) ([]byte, error) {
}
}

ba, err := ioutil.ReadFile(path)
ba, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 4d595ec

Please sign in to comment.