Skip to content

Commit d3d750b

Browse files
committed
fix next block read offset
1 parent fc3f912 commit d3d750b

File tree

423 files changed

+516
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

423 files changed

+516
-4
lines changed

io/linereader/linereader.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,14 @@ func (lr *T) ReadExtra(dst []byte) (nread int, ndiscarted int, err error) {
6262
n := copy(dst, lr.readbuf)
6363
nread += n
6464
lr.readbuf = lr.readbuf[n:]
65-
dst = dst[n:]
6665

6766
if len(lr.readbuf) == 0 && lr.readerErr != nil {
6867
return nread, 0, nil
6968
}
7069
}
7170

7271
for i := uint(0); ; i++ {
73-
readOffset := lr.blocksize * i
74-
//readLimit := armath.Min(readOffset+lr.blocksize, uint(len(dst)))
72+
readOffset := uint(nread)
7573
readLimit := armath.Min(lr.blocksize, uint(len(dst)))
7674

7775
// dst has been filled and there hasn't been a new line yet

io/linereader/linereader_test.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestLineReader(t *testing.T) {
2626
var err error
2727
var n int
2828

29-
for err != io.EOF {
29+
for i := 0; err != io.EOF; i++ {
3030
n, _, err = r.ReadExtra(linesback[:])
3131
if n == 0 && err == io.EOF {
3232
continue
@@ -537,3 +537,30 @@ var reportLineCount int
537537
func init() {
538538
reportLineCount = strings.Count(report, "\n") + 1
539539
}
540+
541+
func TestTruncated(t *testing.T) {
542+
_, currentFile, _, _ := runtime.Caller(0)
543+
currentDir := path.Dir(currentFile)
544+
545+
r, err := readchunkdump.NewReplayer(
546+
path.Join(currentDir, "readerchunkstruncated"),
547+
)
548+
require.NoError(t, err)
549+
lr := linereader.New(r, 1024*4) // 4K read buffer
550+
backingBuf := [20 * 1024 * 1024]byte{} // 20MB max line
551+
552+
for i := 0; ; i++ {
553+
n, dis, rerr := lr.ReadExtra(backingBuf[:])
554+
555+
require.Zero(t, dis)
556+
557+
rb := backingBuf[:n]
558+
559+
if bytes.ContainsRune(rb, '\x00') {
560+
t.FailNow()
561+
}
562+
if rerr == io.EOF {
563+
return
564+
}
565+
}
566+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
INFO: Target 0: /tmp/fuzzcorp-dl-cache/uLb1x50jkHHBmgweIO5aL9vkNGFxveWFAk4ULw/unpacked/lib/libsolfuzz_agave.so
2+
INFO: Target 1: /tmp/fuzzcorp-dl-cache/uLb1x50jkHHBmgweIO5aL9vkNGFxveWFAk4ULw/unpacked/lib/libfd_exec_sol_compat.so
3+
--log-path ""
4+
No log
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INFO: Hardcoded features:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
INFO: Running with entropic power schedule (0xFF, 100).
2+
INFO: Stats reporting: linear
3+
INFO: Seed: 2810793670
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MS: 1 CustomCrossOver-
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NEW_FUNC[1/2]:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0x7c889f4e2840 (/tmp/fuzzcorp-dl-cache/uLb1x50jkHHBmgweIO5aL9vkNGFxveWFAk4ULw/unpacked/lib/libsolfuzz_agave.so+0x2c2b840) (BuildId: bd33607aa1c623f243804dff557a34df86a26961)
2+
NEW_FUNC[2/2]:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0x7c889fe22850 (/tmp/fuzzcorp-dl-cache/uLb1x50jkHHBmgweIO5aL9vkNGFxveWFAk4ULw/unpacked/lib/libsolfuzz_agave.so+0x356b850) (BuildId: bd33607aa1c623f243804dff557a34df86a26961)
2+
#31 NEW cov: 20865 ft: 29023 corp: 27/196Kb lim: 20000 exec/s: 0 rss: 2549Mb L: 3336/13275 MS: 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CustomCrossOver-

0 commit comments

Comments
 (0)