mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
jpeg: add fuzz tests
This commit is contained in:
@@ -19,10 +19,6 @@ type DefineQuantizationTable struct {
|
||||
// Unmarshal decodes the marker.
|
||||
func (m *DefineQuantizationTable) Unmarshal(buf []byte) error {
|
||||
for len(buf) != 0 {
|
||||
if len(buf) < 1 {
|
||||
return fmt.Errorf("image is too short")
|
||||
}
|
||||
|
||||
id := buf[0] & 0x0F
|
||||
precision := buf[0] >> 4
|
||||
buf = buf[1:]
|
||||
|
@@ -67,3 +67,10 @@ func TestDefineQuantizationTableMarshal(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzDefineQuantizationTableUnmarshal(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, b []byte) {
|
||||
var h DefineQuantizationTable
|
||||
h.Unmarshal(b)
|
||||
})
|
||||
}
|
||||
|
@@ -32,3 +32,10 @@ func TestDefineRestartIntervalUnmarshal(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzDefineRestartIntervalUnmarshal(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, b []byte) {
|
||||
var h DefineRestartInterval
|
||||
h.Unmarshal(b)
|
||||
})
|
||||
}
|
||||
|
@@ -47,3 +47,10 @@ func TestStartOfFrame1Marshal(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzStartOfFrame1Unmarshal(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, b []byte) {
|
||||
var h StartOfFrame1
|
||||
h.Unmarshal(b)
|
||||
})
|
||||
}
|
||||
|
@@ -40,3 +40,10 @@ func TestStartOfScanMarshal(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzStartOfScanUnmarshal(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, b []byte) {
|
||||
var h StartOfScan
|
||||
h.Unmarshal(b)
|
||||
})
|
||||
}
|
||||
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("0")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("\x01")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("\b0000\x030!00\x110000")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("\b0000\x030!0000000")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("0")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("000000000000000")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("\b0000\x03000000000")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("\b00000000000000")
|
@@ -0,0 +1,2 @@
|
||||
go test fuzz v1
|
||||
[]byte("0")
|
Reference in New Issue
Block a user