Skip to content

Commit

Permalink
Merge pull request #1737 from lip234/master
Browse files Browse the repository at this point in the history
Fixes #1736
  • Loading branch information
rkervella authored Jul 11, 2024
2 parents 7676fc6 + 8bf4f8e commit bdfd891
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions implant/sliver/ps/ps_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,9 @@ func getArgvFromPid(pid int) ([]string, error) {
errStr := unix.ErrnoName(errno)
return []string{""}, fmt.Errorf("%s", errStr)
}
buffer := bytes.NewBuffer(processArgs)
numberOfArgs, err := binary.ReadUvarint(buffer)
if err != nil {
return []string{""}, err
}
buffer.Next(3) // skip sizeof(int32), the number of args
buffer := bytes.NewBuffer(processArgs[0:size])
numberOfArgsBytes := buffer.Next(4)
numberOfArgs := binary.LittleEndian.Uint32(numberOfArgsBytes)
argv := make([]string, numberOfArgs+1) // executable name is present twice

// There's probably a way to optimize that loop.
Expand All @@ -248,7 +245,7 @@ func getArgvFromPid(pid int) ([]string, error) {
for {
arg, err := buffer.ReadString(0x00)
if err != nil {
continue
break
}
if strings.ReplaceAll(arg, "\x00", "") != "" {
argv[i] = arg
Expand Down

0 comments on commit bdfd891

Please sign in to comment.