Skip to content

Commit 71d6095

Browse files
use-readfull-in-worker (#198)
* prevent potential issues when reading less bytes than expected
1 parent 5e5a7b6 commit 71d6095

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11+
"io"
1112
"io/ioutil"
1213
"os"
1314
"os/signal"
@@ -386,12 +387,12 @@ func main() {
386387
defer cancelExec()
387388
buf := make([]byte, 4)
388389
for {
389-
os.Stdin.Read(buf)
390+
io.ReadFull(os.Stdin, buf)
390391
messageType := binary.BigEndian.Uint32(buf)
391-
os.Stdin.Read(buf)
392+
io.ReadFull(os.Stdin, buf)
392393
messageLength := binary.BigEndian.Uint32(buf)
393394
src := make([]byte, messageLength)
394-
os.Stdin.Read(src)
395+
io.ReadFull(os.Stdin, src)
395396
switch messageType {
396397
case 1:
397398
jobreq := &protocol.AgentJobRequestMessage{}

0 commit comments

Comments
 (0)