Hi Shuai, On Tue, Nov 26, 2024 at 3:20 AM Shuai Zhang <quic_shuaz@xxxxxxxxxxx> wrote: > > This change is required for passing below PTS testcase: > 1. BNEP/CTRL/BV-01-C > > PTS sends an Unknown Control Message with only two bytes, > which is considered incorrect data. Therefore, the handling of > the Unknown Control Message is added before validating the data. > > Signed-off-by: Shuai Zhang <quic_shuaz@xxxxxxxxxxx> > --- > profiles/network/server.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/profiles/network/server.c b/profiles/network/server.c > index 96738f26c..c1d96cd1c 100644 > --- a/profiles/network/server.c > +++ b/profiles/network/server.c > @@ -325,6 +325,32 @@ static gboolean bnep_setup(GIOChannel *chan, > return FALSE; > } > > + /* > + * When benp_control_type is between 0x07 and 0xFF, > + * a reply is also required. > + * However, since the command size is only 2 bytes, > + * it needs to be processed before determining > + * if it is a valid command. > + */ > + if (req->type == BNEP_CONTROL && > + req->ctrl > BNEP_FILTER_MULT_ADDR_RSP) { > + error("bnep: cmd not understood"); > + int err; > + struct bnep_ctrl_cmd_not_understood_cmd rsp; Id probably memset the rsp to 0 to be safe that we don't respond with uninitialized fields. > + rsp.type = BNEP_CONTROL; > + rsp.ctrl = BNEP_CMD_NOT_UNDERSTOOD; > + rsp.unkn_ctrl = (uint8_t) req->ctrl; > + > + err = send(sk, &rsp, sizeof(rsp), 0); > + > + if (err < 0) > + error("send not understood ctrl rsp error: %s (%d)", > + strerror(errno), errno); > + > + return FALSE; Move this code to its own function so it is easier to reuse. > + } > + > /* > * Initial received data packet is BNEP_SETUP_CONNECTION_REQUEST_MSG > * minimal size of this frame is 3 octets: 1 byte of BNEP Type + > -- > 2.25.1 > > -- Luiz Augusto von Dentz