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
This commit is contained in:
Philipp Maier 2022-05-24 17:50:17 +02:00
parent 32aff359ae
commit 9802c14489
1 changed files with 1 additions and 1 deletions

View File

@ -40,7 +40,7 @@ static int get_sw(struct msgb *resp)
{
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);