fuzzer-out util

#
#  Parse / print data types
#
value uint32 0
match 0

value ipaddr 127.0.0.1
match 127.0.0.1

#
#  The rest of the octets should get filled out as 0.
#
value ipaddr 127.0
match 127.0.0.0

#  And canonicalized
value ipaddr 127.0.0.001
match 127.0.0.1

#
#  Time deltas can have qualifiers, but they're always printed
#  as seconds.
#
#  Unless the attribute (which we don't have here) has a scale defined
#
value time_delta 1
match 1

value time_delta 2.4
match 2.4

value time_delta 1ms
match 0.001

value time_delta 1us
match 0.000001

value time_delta 1.5us
match 0.0000015

value time_delta 1ns
match 0.000000001

value time_delta 1:30
match 90

value time_delta 1:1:30
match 3690

value time_delta 01:01:30
match 3690

value time_delta 1h
match 3600

value time_delta 1d
match 86400

#
#  And negative numbers
#
value time_delta -1
match -1

value time_delta -2.4
match -2.4

value time_delta -0.001
match -0.001

value time_delta -1ms
match -0.001

value time_delta -1us
match -0.000001

value time_delta -1.5us
match -0.0000015

value time_delta -1ns
match -0.000000001

value time_delta -1:30
match -90

value time_delta -1:1:30
match -3690

value time_delta -01:01:30
match -3690

value time_delta -1h
match -3600

value time_delta -1d
match -86400

#
#  uint8
#
value uint8 256
match integer overflow

value uint8 -128
match integer underflow

value int8 128
match integer overflow

value int8 -128
match -128

value int8 -130
match integer underflow

value date Jan  1 1970 12:00:00 UTC
match 1970-01-01T12:00:00Z

#
#  10 days in
#
value date 864000
match 1970-01-11T00:00:00Z

# 100 days
value date 8640000
match 1970-04-11T00:00:00Z

# 1,000 days
value date 86400000
match 1972-09-27T00:00:00Z

# 10,000 days
value date 864000000
match 1997-05-19T00:00:00Z

#
#  Input can be whatever.  But for the tests, output is UTC.
#
#  Note that this test is wrong, because the HH:MM are the
#  same, even though they are in different time zones.
#  Our parse function ignores time zones, which is bad.
#
value date Aug 21 2019 07:43:03 EDT
match 2019-08-21T07:43:03Z

#
#  Can't yet test this as the parse / print / parse / cmp
#  functions don't yet allow for choosing ISO8601 vs the
#  traditional FreeRADIUS time.
#
#date 2019-08-21T07:40:31-04:00
#data foo

#
#  Switch fuzzer output to DNS corpus
#
fuzzer-out dns

#
#  DNS labels
#
encode-dns-label foo.com
match 03 66 6f 6f 03 63 6f 6d 00

#
#  Make sure that we can decode the label, too.
#
decode-dns-label -
match foo.com

#
#  Trailing dots are suppressed.
#
encode-dns-label foo.com.
match 03 66 6f 6f 03 63 6f 6d 00


encode-dns-label foo.com,b.ca
match 03 66 6f 6f 03 63 6f 6d 00 01 62 02 63 61 00

decode-dns-label -
match foo.com,b.ca

# root gets encoded as a plain 0.
encode-dns-label .
match 00

decode-dns-label -
match .

# From RFC 1035 Section 4.1.4
encode-dns-label F.ISI.ARPA,FOO.F.ISI.ARPA,ARPA,.
match 01 46 03 49 53 49 04 41 52 50 41 00 03 46 4f 4f c0 00 c0 06 00

decode-dns-label -
match F.ISI.ARPA,FOO.F.ISI.ARPA,ARPA,.

encode-dns-label www.example.com,ftp.example.com,www.ftp.example.com
match 03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 03 66 74 70 c0 04 03 77 77 77 c0 11

decode-dns-label -
match www.example.com,ftp.example.com,www.ftp.example.com

encode-dns-label www.example.com,ftp.example.com,www.example.org,ftp.example.org,ns.example.org
match 03 77 77 77 07 65 78 61 6d 70 6c 65 03 63 6f 6d 00 03 66 74 70 c0 04 03 77 77 77 07 65 78 61 6d 70 6c 65 03 6f 72 67 00 03 66 74 70 c0 1b 02 6e 73 c0 1b

decode-dns-label -
match www.example.com,ftp.example.com,www.example.org,ftp.example.org,ns.example.org

#
#  Underscores are allowed as the first character of a label.
#
encode-dns-label _foo.com
match 04 5f 66 6f 6f 03 63 6f 6d 00

decode-dns-label -
match _foo.com

#
#  Error cases
#
encode-dns-label www.it-is-a-long-crazy-domain-name-just-to-get-63-chars-and-yes-1234.com
match Label is larger than 63 characters

# same as above, but first element
encode-dns-label it-is-a-long-crazy-domain-name-just-to-get-63-chars-and-yes-1234.com
match Label is larger than 63 characters

# same as above, but last element
encode-dns-label www.it-is-a-long-crazy-domain-name-just-to-get-63-chars-and-yes-1234
match Label is larger than 63 characters

encode-dns-label .foo.com
match Empty labels are invalid

encode-dns-label www..foo.com
match Double dots '..' are forbidden

#  underscore as non-first character is illegal
encode-dns-label www_foo.com
match Invalid character 0x5f in label

count
match 120
