dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/28180 )


Change subject: reader: more meaningful null pointer check in get_sw
......................................................................

reader: more meaningful null pointer check in get_sw

At the moment msgb_apdu_de(resp) is used to check if the msgb that is
handed over to get_sw is properly populated with data.

However, since msgb_apdu_de() is just adding an offset, which cannot be
0 to ->l2h the returned value also can never be NULL. This means that we
cannot use msgb_apdu_de() to detect if resp contains a nullpointer.

Lets check if ->l2h is not NULL instead. This will make sure that ->l2h
is populated.

Change-Id: I32bc56c9264c01911a4f4b4f911b09e955205010
Related: OS#5560
---
M src/sim/reader.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/80/28180/1

diff --git a/src/sim/reader.c b/src/sim/reader.c
index b41b730..982b2ee 100644
--- a/src/sim/reader.c
+++ b/src/sim/reader.c
@@ -40,7 +40,7 @@
 {
        int ret;

-       if (!msgb_apdu_de(resp) || msgb_apdu_le(resp) < 2)
+       if (!resp->l2h || msgb_apdu_le(resp) < 2)
                return -EIO;

        ret = msgb_get_u16(resp);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/28180
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I32bc56c9264c01911a4f4b4f911b09e955205010
Gerrit-Change-Number: 28180
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>
Gerrit-MessageType: newchange

Reply via email to