diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2023-05-17 15:05:33 +0200 |
---|---|---|
committer | Philipp Maier <pmaier@sysmocom.de> | 2023-05-22 11:32:06 +0200 |
commit | bc90f9fa34cc1b6d2ff375f9a53e0295808f5546 (patch) | |
tree | 138fe1519027b55ddbba5a177e29be9635ad7a19 | |
parent | 9cc85c1a6a89ca1027deb999f0937c5c84515683 (diff) |
l1sap: Drop invalid HR GSM payload
HR GSM payload is currently not validated. Let's add an
rtppayload_validate_hr function that checks the incoming RTP payload by
its length. Two lengts are valid, depending on which of the two HR GSM
RTP formats (RFC 5993 or TS 101 318) are used.
Change-Id: I453562da412fde5b928bd2b588129c58ec8e2a7e
Related: OS#5688
-rw-r--r-- | src/common/l1sap.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c index f24bc2f7..a59941fd 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -1252,6 +1252,16 @@ static bool rtppayload_validate_fr(struct msgb *msg) return osmo_fr_sid_preen(msg->data); } +static bool rtppayload_validate_hr(struct msgb *msg) +{ + /* Make sure the length of the payload matches one of the possible formats, + * which are ETSI TS 101.318 and RFC 5993 */ + if (OSMO_UNLIKELY((msg->len != GSM_HR_BYTES_RTP_TS101318) + && (msg->len != GSM_HR_BYTES_RTP_RFC5993))) + return false; + return true; +} + static bool rtppayload_validate_efr(struct msgb *msg) { if (msg->len != GSM_EFR_BYTES) @@ -1280,7 +1290,7 @@ static bool rtppayload_is_valid(struct gsm_lchan *lchan, struct msgb *resp_msg) if (lchan->type == GSM_LCHAN_TCH_F) return rtppayload_validate_fr(resp_msg); else - return true; /* FIXME: implement preening for HR1 */ + return rtppayload_validate_hr(resp_msg); case GSM48_CMODE_SPEECH_EFR: return rtppayload_validate_efr(resp_msg); case GSM48_CMODE_SPEECH_AMR: |