Skip to content

Commit 3fac826

Browse files
committed
DCP identify return false if it hasn't handled a request
The function pf_dcp_identify_req, would return 1 even if the request wasn't handled by it, this would lead to replies to invalid requests sent to the device. Fixing this so that it only returns 1 if the request being made passes the necessary checks. Fixed the invalid ident_req array in the gtests, filled with proper station name, and tests now check if the station name, dcp data length and dcp block length are correct for packets.
1 parent 2b595ad commit 3fac826

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/common/pf_dcp.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,15 @@ static int pf_dcp_identify_req (
15261526
src_pos += sizeof (*p_src_block_hdr); /* Point to the block value */
15271527

15281528
src_block_len = ntohs (p_src_block_hdr->block_length);
1529+
/* Check if we have a valid dcp data length */
1530+
if (!(src_dcplen >= (src_pos + src_block_len)))
1531+
{
1532+
ret = -1;
1533+
}
1534+
else {
1535+
match = true; /* So far so good */
1536+
}
15291537

1530-
match = true; /* So far so good */
15311538
while ((ret == 0) && (first || (filter && match)) &&
15321539
(src_dcplen >= (src_pos + src_block_len)) &&
15331540
(dst_pos < PF_FRAME_BUFFER_SIZE))
@@ -1953,6 +1960,11 @@ static int pf_dcp_identify_req (
19531960
pnal_buf_free (p_buf);
19541961
}
19551962

1963+
if ((ret <= 0) && (match == false))
1964+
{
1965+
return ret; /* Not handled, not matched or something went wrong */
1966+
}
1967+
19561968
return 1; /* Means: handled */
19571969
}
19581970

src/device/pf_cmina.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ int pf_cmina_dcp_get_req (
11291129
*pp_value = (uint8_t *)net->cmina_current_dcp_ase.product_name;
11301130
break;
11311131
case PF_DCP_SUB_DEV_PROP_NAME:
1132-
*p_value_length = sizeof (net->cmina_current_dcp_ase.station_name);
1132+
*p_value_length = strlen(net->cmina_current_dcp_ase.station_name);
11331133
*pp_value = (uint8_t *)net->cmina_current_dcp_ase.station_name;
11341134
break;
11351135
case PF_DCP_SUB_DEV_PROP_ID:

test/test_dcp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static uint8_t get_name_req[] = {
5454

5555
static uint8_t ident_req[] = {
5656
0x01, 0x0e, 0xcf, 0x00, 0x00, 0x00, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
57-
0x88, 0x92, 0xfe, 0xfe, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,
57+
0x88, 0x92, 0xfe, 0xfe, 0x05, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
5858
0x00, 0x10, 0x02, 0x02, 0x00, 0x0c, 0x72, 0x74, 0x2d, 0x6c, 0x61, 0x62,
5959
0x73, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6060
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

0 commit comments

Comments
 (0)