1# The proof depends on one parameter:
2#   NETWORK_BUFFER_SIZE is the size of the network buffer being parsed
3# The buffer size must be bounded because we must bound the number of
4# iterations loops iterating over the buffer.
5
6{
7  "ENTRY": "ParseDNSReply",
8
9################################################################
10# This is the network buffer size.
11# Reasonable values are size > 12 = sizeof(xDNSMessage)
12  "NETWORK_BUFFER_SIZE": 40,
13
14################################################################
15# This is the size of the buffer into which the name is copied.
16# Set to any positive value.
17# In the source, NAME_SIZE=254 and NETWORK_BUFFER_SIZE >> NAME_SIZE
18# In the proof, NAME_SIZE >= 4 required for good coverage.
19  "NAME_SIZE":  "10",
20
21################################################################
22# Loop prvParseDNSReply.0:
23# file lib/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS.c line 915
24  "PARSELOOP0": "prvParseDNSReply.0",
25
26# M = sizeof( DNSMessage_t ) = 12
27# U = sizeof( uint32_t) = 4
28# Loop bound is (NETWORK_BUFFER_SIZE - M) div (U+1) + 1 tight for SIZE >= M
29# Loop bound is 1 for 0 <= SIZE < M
30  "PARSELOOP0_UNWIND":
31    "__eval 1 if {NETWORK_BUFFER_SIZE} < 12 else ({NETWORK_BUFFER_SIZE} - 12) / 5 + 1",
32
33################################################################
34# Loop prvParseDNSReply.1:
35# file lib/FreeRTOS-Plus-TCP/source/FreeRTOS_DNS.c line 989
36  "PARSELOOP1": "prvParseDNSReply.1",
37
38# A = sizeof( DNSAnswerRecord_t ) = 10
39# M = sizeof( DNSMessage_t ) = 12
40# U = sizeof( uint32_t) = 4
41# Loop bound is (NETWORK_BUFFER_SIZE - M - A) div (A+1) + A + 1 tight
42#    for SIZE >= M + A
43# Loop bound is (NETWORK_BUFFER_SIZE - M) + 1 for M <= SIZE < M + A
44# Loop bound is 1 for 0 <= SIZE < M
45  "PARSELOOP1_UNWIND":
46    "__eval 1 if {NETWORK_BUFFER_SIZE} < 12 else ({NETWORK_BUFFER_SIZE} - 11 if {NETWORK_BUFFER_SIZE} < 22 else ({NETWORK_BUFFER_SIZE} - 12 - 10) / 11 + 11)",
47
48################################################################
49
50  "CBMCFLAGS":
51  [
52    "--unwind 1",
53    "--unwindset {PARSELOOP0}:{PARSELOOP0_UNWIND},{PARSELOOP1}:{PARSELOOP1_UNWIND},prvProcessDNSCache.0:5"
54  ],
55
56  "OBJS":
57  [
58    "$(ENTRY)_harness.goto",
59    "$(FREERTOS_PLUS_TCP)/source/FreeRTOS_DNS.goto",
60    "$(FREERTOS_PLUS_TCP)/test/FreeRTOS-Kernel/tasks.goto"
61  ],
62
63  "DEF":
64  [
65    "NETWORK_BUFFER_SIZE={NETWORK_BUFFER_SIZE}",
66    "NAME_SIZE={NAME_SIZE}"
67  ]
68}
69