Change in osmo-pcu[master]: csn1: fix csnStreamEncoder(): also check length of the choice list
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/18431 ) Change subject: csn1: fix csnStreamEncoder(): also check length of the choice list .. csn1: fix csnStreamEncoder(): also check length of the choice list Similar checks are done in csnStreamDecoder(), so better check than sorry. Change-Id: I441c716975905a37264efc8a76df92194f39c1fb --- M src/csn1.c 1 file changed, 7 insertions(+), 1 deletion(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved pespin: Looks good to me, approved diff --git a/src/csn1.c b/src/csn1.c index 3347a64..700c342 100644 --- a/src/csn1.c +++ b/src/csn1.c @@ -1802,10 +1802,16 @@ case CSN_CHOICE: { -//gint16 count = pDescr->i; +gint16 count = pDescr->i; guint8 i = 0; const CSN_ChoiceElement_t* pChoice = (const CSN_ChoiceElement_t*) pDescr->descr.ptr; +/* Make sure that the list of choice items is not empty */ +if (!count) + return ProcessError(writeIndex, "csnStreamEncoder", CSN_ERROR_IN_SCRIPT, pDescr); +else if (count > 255) /* We can handle up to 256 (UCHAR_MAX) selectors */ + return ProcessError(writeIndex, "csnStreamEncoder", CSN_ERROR_IN_SCRIPT, pDescr); + pui8 = pui8DATA(data, pDescr->offset); i = *pui8; pChoice += i; -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/18431 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I441c716975905a37264efc8a76df92194f39c1fb Gerrit-Change-Number: 18431 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: pespin Gerrit-MessageType: merged
Change in osmo-pcu[master]: csn1: fix csnStreamEncoder(): also check length of the choice list
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/18431 ) Change subject: csn1: fix csnStreamEncoder(): also check length of the choice list .. Patch Set 1: Code-Review+2 (1 comment) https://gerrit.osmocom.org/c/osmo-pcu/+/18431/1/src/csn1.c File src/csn1.c: https://gerrit.osmocom.org/c/osmo-pcu/+/18431/1/src/csn1.c@1812 PS1, Line 1812: else if (count > 255) /* We can handle up to 256 (UCHAR_MAX) selectors */ you can simply write if here, since you are returning in the if above if it holds true. -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/18431 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I441c716975905a37264efc8a76df92194f39c1fb Gerrit-Change-Number: 18431 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: pespin Gerrit-Comment-Date: Mon, 25 May 2020 08:46:38 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-pcu[master]: csn1: fix csnStreamEncoder(): also check length of the choice list
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/18431 ) Change subject: csn1: fix csnStreamEncoder(): also check length of the choice list .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/18431 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I441c716975905a37264efc8a76df92194f39c1fb Gerrit-Change-Number: 18431 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Comment-Date: Sun, 24 May 2020 07:56:13 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
Change in osmo-pcu[master]: csn1: fix csnStreamEncoder(): also check length of the choice list
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/18431 ) Change subject: csn1: fix csnStreamEncoder(): also check length of the choice list .. csn1: fix csnStreamEncoder(): also check length of the choice list Similar checks are done in csnStreamDecoder(), so better check than sorry. Change-Id: I441c716975905a37264efc8a76df92194f39c1fb --- M src/csn1.c 1 file changed, 7 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/31/18431/1 diff --git a/src/csn1.c b/src/csn1.c index 3347a64..700c342 100644 --- a/src/csn1.c +++ b/src/csn1.c @@ -1802,10 +1802,16 @@ case CSN_CHOICE: { -//gint16 count = pDescr->i; +gint16 count = pDescr->i; guint8 i = 0; const CSN_ChoiceElement_t* pChoice = (const CSN_ChoiceElement_t*) pDescr->descr.ptr; +/* Make sure that the list of choice items is not empty */ +if (!count) + return ProcessError(writeIndex, "csnStreamEncoder", CSN_ERROR_IN_SCRIPT, pDescr); +else if (count > 255) /* We can handle up to 256 (UCHAR_MAX) selectors */ + return ProcessError(writeIndex, "csnStreamEncoder", CSN_ERROR_IN_SCRIPT, pDescr); + pui8 = pui8DATA(data, pDescr->offset); i = *pui8; pChoice += i; -- To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/18431 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-pcu Gerrit-Branch: master Gerrit-Change-Id: I441c716975905a37264efc8a76df92194f39c1fb Gerrit-Change-Number: 18431 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria Gerrit-MessageType: newchange