Attention is currently required from: neels.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-iuh/+/37414?usp=email )
Change subject: ranap_cn_rx_co(): do not ranap_cn_rx_co_free() on error
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/37414?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: If7545f91c69f06bc32c55cab7dcfcad8350b0473
Gerrit-Change-Number: 37414
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Comment-Date: Tue, 16 Jul 2024 17:01:01 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-iuh/+/37413?usp=email )
Change subject: fix memleak: free after aper_decode() also on error
......................................................................
fix memleak: free after aper_decode() also on error
It turns out that aper_decode() wants the caller to ASN_STRUCT_FREE()
always, also even when it returned != RC_OK.
When during a test I was feeding random data (a BSSMAP message) to
ranap_cn_rx_co_decode2(), I ended up with ASAN indicating a memory leak:
```
pkt DEBUG packet.1 RANAP 01 00 03 05 18 01 (decode_iu.c:658)
tag ERROR Error in RANAP ASN.1 decode (ranap_common_cn.c:401)
tag ERROR Not calling cn_ranap_handle_co() due to rc=-1 (ranap_common_cn.c:428)
pkt ERROR packet.1 RANAP failed to decode RANAP data (decode_iu.c:668)
=================================================================
==1920572==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 208 byte(s) in 1 object(s) allocated from:
#0 0x7f34520f3bc7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f34526ccddd (/lib/x86_64-linux-gnu/libtalloc.so.2+0x5ddd) (BuildId: 75c550e5dc091c77e1159c52b284f34d0c4d92cd)
Indirect leak of 102 byte(s) in 1 object(s) allocated from:
#0 0x7f34520f3bc7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69
#1 0x7f34526ccddd (/lib/x86_64-linux-gnu/libtalloc.so.2+0x5ddd) (BuildId: 75c550e5dc091c77e1159c52b284f34d0c4d92cd)
SUMMARY: AddressSanitizer: 310 byte(s) leaked in 2 allocation(s).
```
With this patch, the leak is gone.
Change-Id: I03ed2376e520ec6dbcc2bae22f9291e211c7cca9
---
M src/ranap_common_cn.c
1 file changed, 43 insertions(+), 2 deletions(-)
Approvals:
daniel: Looks good to me, approved
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
diff --git a/src/ranap_common_cn.c b/src/ranap_common_cn.c
index 72698a4..81dcdca 100644
--- a/src/ranap_common_cn.c
+++ b/src/ranap_common_cn.c
@@ -387,13 +387,15 @@
dec_ret = aper_decode(NULL, &asn_DEF_RANAP_RANAP_PDU, (void **)&pdu, data, len, 0, 0);
if (dec_ret.code != RC_OK) {
LOGP(DRANAP, LOGL_ERROR, "Error in RANAP ASN.1 decode\n");
- return -1;
+ rc = -1;
+ goto error_free;
}
message->direction = pdu->present;
rc = _cn_ranap_rx_co(pdu, message);
+error_free:
ASN_STRUCT_FREE(asn_DEF_RANAP_RANAP_PDU, pdu);
return rc;
@@ -633,13 +635,15 @@
dec_ret = aper_decode(NULL, &asn_DEF_RANAP_RANAP_PDU, (void **)&pdu, data, len, 0, 0);
if (dec_ret.code != RC_OK) {
LOGP(DRANAP, LOGL_ERROR, "Error in RANAP ASN.1 decode\n");
- return -1;
+ rc = -1;
+ goto error_free;
}
message->direction = pdu->present;
rc = _cn_ranap_rx_cl(pdu, message);
+error_free:
ASN_STRUCT_FREE(asn_DEF_RANAP_RANAP_PDU, pdu);
return rc;
--
To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/37413?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Change-Id: I03ed2376e520ec6dbcc2bae22f9291e211c7cca9
Gerrit-Change-Number: 37413
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37496?usp=email )
Change subject: pySim.esim.http_json_api: 'header' is not always present in response
......................................................................
pySim.esim.http_json_api: 'header' is not always present in response
For example, the ES9+ handleNotification function is defined with an
empty response body, so we cannot unconditionally assume that every HTTP
response will contain a JSON "header" value.
Change-Id: Ia3c5703b746c1eba91f85f8545f849a3f2d56e0b
---
M pySim/esim/http_json_api.py
1 file changed, 26 insertions(+), 10 deletions(-)
Approvals:
dexter: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
diff --git a/pySim/esim/http_json_api.py b/pySim/esim/http_json_api.py
index 377faea..6a803f2 100644
--- a/pySim/esim/http_json_api.py
+++ b/pySim/esim/http_json_api.py
@@ -204,16 +204,17 @@
return output
def decode(self, data: dict) -> dict:
- """[further] Decode and validate the JSON-Dict of the respnse body."""
+ """[further] Decode and validate the JSON-Dict of the response body."""
output = {}
- # let's first do the header, it's special
- if not 'header' in data:
- raise ValueError('Mandatory output parameter "header" missing')
- hdr_class = self.output_params.get('header')
- output['header'] = hdr_class.decode(data['header'])
+ if 'header' in self.output_params:
+ # let's first do the header, it's special
+ if not 'header' in data:
+ raise ValueError('Mandatory output parameter "header" missing')
+ hdr_class = self.output_params.get('header')
+ output['header'] = hdr_class.decode(data['header'])
- if output['header']['functionExecutionStatus']['status'] not in ['Executed-Success','Executed-WithWarning']:
- raise ApiError(output['header']['functionExecutionStatus'])
+ if output['header']['functionExecutionStatus']['status'] not in ['Executed-Success','Executed-WithWarning']:
+ raise ApiError(output['header']['functionExecutionStatus'])
# we can only expect mandatory parameters to be present in case of successful execution
for p in self.output_mandatory:
if p == 'header':
@@ -229,7 +230,7 @@
output[p] = p_class.decode(v)
return output
- def call(self, data: dict, func_call_id: Optional[str] = None, timeout=10) -> dict:
+ def call(self, data: dict, func_call_id: Optional[str] = None, timeout=10) -> Optional[dict]:
"""Make an API call to the HTTP API endpoint represented by this object.
Input data is passed in `data` as json-serializable dict. Output data
is returned as json-deserialized dict."""
@@ -253,4 +254,6 @@
if not response.headers.get('X-Admin-Protocol', 'gsma/rsp/v2.unknown').startswith('gsma/rsp/v2.'):
raise HttpHeaderError(response)
- return self.decode(response.json())
+ if response.content:
+ return self.decode(response.json())
+ return None
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37496?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia3c5703b746c1eba91f85f8545f849a3f2d56e0b
Gerrit-Change-Number: 37496
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: laforge.
dexter has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37511?usp=email )
Change subject: osmo-smdpp + es9p_client: HTTP status 204 is used for handleNotification
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
Patchset:
PS2:
This should be correct, I noticed this behavior in the wild as well.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37511?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I890bdbd3e1c4578d2d5f0367958fdce26e338cac
Gerrit-Change-Number: 37511
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Tue, 16 Jul 2024 15:19:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment