From 0c083e5cb0170af53b17813a9661c7cbe99a3e27 Mon Sep 17 00:00:00 2001 From: rootkiller6788 Date: Thu, 20 Aug 2026 15:19:08 +0800 Subject: [PATCH] Fuzz RTCM3 frame validation --- rtcm/rtcm_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/rtcm/rtcm_test.go b/rtcm/rtcm_test.go index 9d7f4dc0..9c48fd00 100644 --- a/rtcm/rtcm_test.go +++ b/rtcm/rtcm_test.go @@ -225,3 +225,25 @@ func TestParseFrameExtraTrailingData(t *testing.T) { // Raw should be only the frame, not the trailing bytes. require.Len(t, frame.Raw, HeaderSize+20+CRCSize) } + +// FuzzParseFrame fuzzes RTCM3 frame validation. ParseFrame sits on the hot path +// for every GNSS correction stream the daemon ingests (see cmd/ntripper), and +// the input is untrusted network data, so no input may panic or hang it. +func FuzzParseFrame(f *testing.F) { + for _, seed := range [][]byte{ + {}, + {0}, + {9}, + buildFrame(buildPayloadWithType(TypeStationARP, 20)), + buildFrame(buildPayloadWithType(TypeGPSMSM7, 100)), + buildFrame(buildPayloadWithType(TypeGLONASSBiases, 10)), + buildFrame(make([]byte, MaxPayloadLen)), + buildFrame(nil), + {0xD3, 0x00, 0x00, 0x00, 0x00, 0x00}, + } { + f.Add(seed) + } + f.Fuzz(func(t *testing.T, b []byte) { + _, _ = ParseFrame(b) + }) +}