Skip to content

Commit 8929b2d

Browse files
Switched the atomics to Bools
1 parent d7337e1 commit 8929b2d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

c2/cli/basic.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import (
1515

1616
// A very basic reverse/bind shell handler.
1717
func Basic(conn net.Conn) {
18-
var shutdown int32 = 0
18+
19+
var shutdown atomic.Bool
20+
shutdown.Store(false)
21+
1922
// Create channels for communication between goroutines.
2023
responseCh := make(chan string)
2124

@@ -29,11 +32,11 @@ func Basic(conn net.Conn) {
2932
defer func (){
3033
// Signals for both routines to stop, this should get triggered when socket is closed
3134
// and causes it to fail the read
32-
atomic.StoreInt32(&shutdown, 1)
35+
shutdown.Store(true)
3336
}()
3437
responseBuffer := make([]byte, 1024)
3538
for {
36-
if atomic.LoadInt32(&shutdown) == 1 {
39+
if shutdown.Load() {
3740
return
3841
}
3942
select {
@@ -61,7 +64,7 @@ func Basic(conn net.Conn) {
6164
go func() {
6265
defer wg.Done()
6366
for {
64-
if atomic.LoadInt32(&shutdown) == 1 {
67+
if shutdown.Load() {
6568
return
6669
}
6770
select {
@@ -81,7 +84,7 @@ func Basic(conn net.Conn) {
8184
for {
8285
reader := bufio.NewReader(os.Stdin)
8386
command,_ := reader.ReadString('\n')
84-
if atomic.LoadInt32(&shutdown) == 1 {
87+
if shutdown.Load() {
8588
break
8689
}
8790
ok := protocol.TCPWrite(conn, []byte(command))

0 commit comments

Comments
 (0)