Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

5G NAS UE policy protocol TS 24.501_UEPOL UPSISublist Len field is not encoded. #252

Open
maddenj-ie opened this issue Dec 14, 2023 · 1 comment

Comments

@maddenj-ie
Copy link

The 'Len' field of UPSISublist is not encoded when using 'to_bytes'

The issue may be reproduced using the following test

    def test_upsi_sublist_from_obj_to_bytes(self):

        upsi_sublist_obj = UPSISublist(val={
            'PLMN': '27201',
            'Cont': [
                1,
                2
            ]
        })

        show(upsi_sublist_obj)

        upsi_sublist_bytes = upsi_sublist_obj.to_bytes()
        print(upsi_sublist_obj.hex())

        expected_upsi_sublist_bytes = b'\x00\x07\x72\xf2\x10\x00\x01\x00\x02'

        assert upsi_sublist_bytes == expected_upsi_sublist_bytes

There is no 'init' method associated with the UPSISublist class.

class UPSISublist(Envelope):

I've done some experimenting and the addition of the following code, resolves the issue.

    def __init__(self, *args, **kwargs):
        Envelope.__init__(self, *args, **kwargs)
        self[0].set_valauto(lambda: 3 + self[2].get_len())
        self[2].set_blauto(lambda: (self[0].get_val()-3) << 3)

I'm happy to assist with testing.

Thanks.

@mitshell
Copy link
Contributor

mitshell commented Mar 1, 2024

Thanks for uncovering this bug, too.
Same as with previous issue, a new repository has been setup, including new fixes. This repo will keep being maintained : https://github.com/pycrate-org/pycrate. It includes fixes for this specific 5G NAS module. Moreover, it will ease collaborative support !

If you checkout the last 0.7.1 version, this bug should be solved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants