Skip to content

Commit

Permalink
test oom while de-serializing beacon
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Nov 2, 2024
1 parent 7cfc0ac commit 6803a30
Show file tree
Hide file tree
Showing 3 changed files with 261 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/java/ru/r2cloud/jradio/eirsat/EirsatBeacon.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void readBeacon(DataInputStream dis) throws IOException, UncorrectableExc
partial.setPayload(payload);
packets.add(partial);
}
while (!Thread.currentThread().isInterrupted()) {
while (!Thread.currentThread().isInterrupted() && dis.available() > 0) {
try {
packets.add(new Packet(dis));
} catch (UncorrectableException e) {
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/ru/r2cloud/jradio/eirsat/EirsatBeaconTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ public void testUnknown() throws Exception {
AssertJson.assertObjectsEqual("EirsatBeacon-unknown.json", result);
}

@Test
public void testOom() throws Exception {
byte[] data = new byte[] { -69, 89, -112, -86, 112, 11, 127, 19, -10, 95, 40, -12, 55, 29, 54, -59, 37, -124, -117, -109, 26, 86, -120, 35, 60, -43, -44, 12, 31, 94, -16, -25, 118, -77, 33, 84, -32, 22, -2, 39, -20, -66, 81, -24, 110, 58, 109, -118, 75, 9, 23, 38, 52, -83, 16, 70, 121, -85,
-88, 24, 62, -67, -31, -50, -19, 102, 66, -87, -64, 45, -4, 79, -39, 124, -93, -48, -36, 116, -37, 20, -106, 18, 46, 76, 105, 90, 32, -116, -13, 87, 80, 48, 125, 123, -61, -99, -38, -52, -123, 83, -128, 91, -8, -97, -78, -7, 71, -95, -72, -23, -74, 41, 44, 36, 92, -104, -46, -76, 65,
25, -26, -82, -96, 96, -6, -9, -121, 59, -75, -103, 10, -89, 0, -73, -15, 63, 101, -14, -113, 67, 113, -45, 108, 82, 88, 72, -71, 49, -91, 104, -126, 51, -51, 93, 64, -63, -11, -17, 14, 119, 107, 50, 21, 78, 1, 111, -30, 126, -53, -27, 30, -122, -29, -90, -40, -92, -80, -111, 114,
99, 74, -47, 4, 103, -102, -70, -127, -125, -21, -34, 28, -18, -42, 100, 42, -100, 2, -33, -60, -3, -105, -54, 61, 13, -57, 77, -79, 73, 97, 34, -28, -58, -107, -94, 8, -49, 53, 117, 3, 7, -41, -68, 57 };
EirsatBeacon result = new EirsatBeacon();
result.readBeacon(data);
AssertJson.assertObjectsEqual("EirsatBeacon-oom.json", result);
}

@Test
public void testPojo() {
assertThat(EirsatBeacon.class, allOf(hasValidBeanConstructor(), hasValidGettersAndSetters()));
Expand Down
249 changes: 249 additions & 0 deletions src/test/resources/expected/EirsatBeacon-oom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"packets": [
{
"payload": [
127,
19,
-10,
95,
40,
-12,
55,
29,
54,
-59,
37
]
},
{
"header": {
"packetVersion": 4,
"packetType": 0,
"secondaryHeader": false,
"applicationProcessId": 1163,
"sequenceFlag": 2,
"packetName": 4890,
"packetDataLength": 22152
},
"payload": [
35,
60,
-43,
-44,
12,
31,
94,
-16,
-25,
118,
-77,
33,
84,
-32,
22,
-2,
39,
-20,
-66,
81,
-24,
110,
58,
109,
-118,
75,
9,
23,
38,
52,
-83,
16,
70,
121,
-85,
-88,
24,
62,
-67,
-31,
-50,
-19,
102,
66,
-87,
-64,
45,
-4,
79,
-39,
124,
-93,
-48,
-36,
116,
-37,
20,
-106,
18,
46,
76,
105,
90,
32,
-116,
-13,
87,
80,
48,
125,
123,
-61,
-99,
-38,
-52,
-123,
83,
-128,
91,
-8,
-97,
-78,
-7,
71,
-95,
-72,
-23,
-74,
41,
44,
36,
92,
-104,
-46,
-76,
65,
25,
-26,
-82,
-96,
96,
-6,
-9,
-121,
59,
-75,
-103,
10,
-89,
0,
-73,
-15,
63,
101,
-14,
-113,
67,
113,
-45,
108,
82,
88,
72,
-71,
49,
-91,
104,
-126,
51,
-51,
93,
64,
-63,
-11,
-17,
14,
119,
107,
50,
21,
78,
1,
111,
-30,
126,
-53,
-27,
30,
-122,
-29,
-90,
-40,
-92,
-80,
-111,
114,
99,
74,
-47,
4,
103,
-102,
-70,
-127,
-125,
-21,
-34,
28,
-18,
-42,
100,
42,
-100,
2,
-33,
-60,
-3,
-105,
-54,
61,
13,
-57,
77,
-79,
73,
97,
34,
-28,
-58,
-107,
-94,
8,
-49,
53,
117,
3
]
}
],
"header": {
"version": 2,
"spacecraftId": 949,
"virtualChannelId": 4,
"ocf": true,
"masterChannelFrameCount": 144,
"virtualChannelFrameCount": 170,
"fieldStatus": {
"secondaryHeader": false,
"sync": true,
"packetOrder": true,
"segmentLengthId": 2,
"firstHeaderPointer": 11
}
},
"ocf": {
"type": 0
},
"beginSample": 0,
"beginMillis": 0,
"endSample": 0
}

0 comments on commit 6803a30

Please sign in to comment.