dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/onomondo-ipa/+/42872?usp=email )


Change subject: es10b_get_euicc_info: add explanatory comments regarding 
EUICCInfo2
......................................................................

es10b_get_euicc_info: add explanatory comments regarding EUICCInfo2

onomondo-ipa has a built-in IoT eUICC emulation. This means that we
have to deal with two different EUICCInfo2 formats, which requires
additional logic in ipa_es10b_get_euicc_info_free to free the
allocated structs correctly. Since it is not immediately obvious
how the logic works, let's add some explanary comments to make it
obvious.

Related: SYS#8101
Change-Id: I282fa91a4099a771a353101b0ce17ae3daae9c42
---
M src/ipa/libipa/es10b_get_euicc_info.c
1 file changed, 15 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/onomondo-ipa refs/changes/72/42872/1

diff --git a/src/ipa/libipa/es10b_get_euicc_info.c 
b/src/ipa/libipa/es10b_get_euicc_info.c
index db9c541..a0aba7d 100644
--- a/src/ipa/libipa/es10b_get_euicc_info.c
+++ b/src/ipa/libipa/es10b_get_euicc_info.c
@@ -105,14 +105,15 @@
        if (!asn)
                return -EINVAL;

+       /* Present EUICCInfo2 in SGP.32 format (see comment in header file) */
        euicc_info->euicc_info_2 = asn;

-       /* Also offer EUICCInfo2 in SGP.32 format */
+       /* Present derived EUICCInfo2 in SGP.32 format */
        euicc_info->sgp32_euicc_info_2 = IPA_ALLOC(struct SGP32_EUICCInfo2);
        convert_euicc_info_2(euicc_info->sgp32_euicc_info_2, 
euicc_info->euicc_info_2);

        return 0;
-}
+}q

 static int dec_get_euicc_info2_sgp32(struct ipa_es10b_euicc_info *euicc_info, 
const struct ipa_buf *es10b_res)
 {
@@ -122,6 +123,10 @@
        if (!asn)
                return -EINVAL;

+       /* We do not present EUICCInfo2 in SGP.22 in this case (see comment in 
header file) */
+       euicc_info->euicc_info_2 = NULL;
+
+       /* Present derived EUICCInfo2 in SGP.32 format */
        euicc_info->sgp32_euicc_info_2 = asn;

        return 0;
@@ -190,9 +195,17 @@
        ASN_STRUCT_FREE(asn_DEF_EUICCInfo1, res->euicc_info_1);

        if (res->euicc_info_2) {
+               /* res->sgp32_euicc_info_2 has been created from 
res->euicc_info_2 (see also dec_get_euicc_info2). This
+                * means that res->euicc_info_2 holds the original output of 
the ASN.1 decoder while
+                * res->sgp32_euicc_info_2 only holds pointers to 
res->euicc_info_2. This is the reason why we use
+                * ASN_STRUCT_FREE on res->euicc_info_2 and IPA_FREE on 
res->sgp32_euicc_info_2.
+                * (see also comment in header file) */
                IPA_FREE(res->sgp32_euicc_info_2);
                ASN_STRUCT_FREE(asn_DEF_EUICCInfo2, res->euicc_info_2);
        } else {
+               /* res->sgp32_euicc_info_2 has been decoded by the ASN.1 
decoder, so we have to use the ASN_STRUCT_FREE
+                * to free it. (res->euicc_info_2 NULL in this case and does 
not require freeing.
+                * (see also dec_get_euicc_info2_sgp32) */
                ASN_STRUCT_FREE(asn_DEF_SGP32_EUICCInfo2, 
res->sgp32_euicc_info_2);
        }


--
To view, visit https://gerrit.osmocom.org/c/onomondo-ipa/+/42872?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: onomondo-ipa
Gerrit-Branch: master
Gerrit-Change-Id: I282fa91a4099a771a353101b0ce17ae3daae9c42
Gerrit-Change-Number: 42872
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>

Reply via email to