mirror of
https://github.com/hackerschoice/segfault.git
synced 2024-06-25 16:28:37 +00:00
add more checks based on @skyperTHC MR
Signed-off-by: aog <theaog@users.noreply.github.com>
This commit is contained in:
parent
3fb0b0639f
commit
3ec6516fb5
@ -362,12 +362,25 @@ func printProcs(cid string) error {
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
cmdline := fmt.Sprintf("/proc/%s/cmdline", scanner.Text())
|
||||
|
||||
// limit each command string to max 255 characters
|
||||
if len(cmdline) > 255 {
|
||||
cmdline = cmdline[:255]
|
||||
}
|
||||
|
||||
file, err := os.Open(cmdline)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var count int
|
||||
_scanner := bufio.NewScanner(file)
|
||||
for _scanner.Scan() {
|
||||
if count > 128 {
|
||||
return fmt.Errorf("reached 128 commands, skipping extra output")
|
||||
}
|
||||
count++
|
||||
|
||||
data := sanitize(_scanner.Text())
|
||||
log.Warnf("proc: %v", data)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user