From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbT9O-0003A3-8S for qemu-devel@nongnu.org; Mon, 14 Sep 2015 08:46:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbT9I-00087k-9l for qemu-devel@nongnu.org; Mon, 14 Sep 2015 08:46:26 -0400 Received: from mail-oi0-x22e.google.com ([2607:f8b0:4003:c06::22e]:36646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbT9I-00087G-4Y for qemu-devel@nongnu.org; Mon, 14 Sep 2015 08:46:20 -0400 Received: by oibi136 with SMTP id i136so75923360oib.3 for ; Mon, 14 Sep 2015 05:46:19 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87zj0pp5er.fsf@blackfin.pond.sub.org> References: <1426776830-31961-1-git-send-email-thuth@linux.vnet.ibm.com> <87zj0pp5er.fsf@blackfin.pond.sub.org> Date: Mon, 14 Sep 2015 14:46:19 +0200 Message-ID: From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH] libcacard: Fix bug detected with 'smatch' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Jeremy White , Thomas Huth , QEMU Hi On Mon, Sep 14, 2015 at 2:11 PM, Markus Armbruster wrot= e: > Stumbled over this while throwing out old mail. Copying Marc-Andr=C3=A9 = and > Jeremy. > Thanks, the patch is applied in my libcacard "next" branch (https://github.com/elmarco/libcacard/tree/next). > Thomas Huth writes: > >> 'smatch' complains about two bugs and one style issue in card_7816.c: >> >> libcacard/card_7816.c:273 vcard_apdu_set_length() warn: should this be a= bitwise op? >> libcacard/card_7816.c:295 vcard_apdu_set_length() warn: should this be a= bitwise op? >> libcacard/card_7816.c:661 vcard7816_vm_process_apdu() warn: inconsistent= indenting >> >> ... and indeed, the code seems to be wrong here. Let's fix this >> by using a bitwise OR instead of logical OR and by indenting >> the code with the right level. >> >> Signed-off-by: Thomas Huth >> --- >> Please note that this is compile-tested only. I don't have a clue >> about that libcacard stuff, so if you feel confident in this area, >> please have a look whether this change really makes sense. >> --- >> libcacard/card_7816.c | 6 +++--- >> 1 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c >> index 814fa16..0f7a006 100644 >> --- a/libcacard/card_7816.c >> +++ b/libcacard/card_7816.c >> @@ -270,7 +270,7 @@ vcard_apdu_set_length(VCardAPDU *apdu) >> } >> /* calculate the first extended value. Could be either Le o= r Lc */ >> Le =3D (apdu->a_header->ah_body[0] << 8) >> - || apdu->a_header->ah_body[1]; >> + | apdu->a_header->ah_body[1]; >> if (L =3D=3D 3) { >> /* 2E extended, return data only */ >> /* zero maps to 65536 */ >> @@ -292,7 +292,7 @@ vcard_apdu_set_length(VCardAPDU *apdu) >> if (L =3D=3D Le+5) { >> /* 4E extended, parameters and return data */ >> Le =3D (apdu->a_data[apdu->a_len-2] << 8) >> - || apdu->a_data[apdu->a_len-1]; >> + | apdu->a_data[apdu->a_len-1]; >> apdu->a_Le =3D Le ? Le : 65536; >> return VCARD7816_STATUS_SUCCESS; >> } >> @@ -657,7 +657,7 @@ vcard7816_vm_process_apdu(VCard *card, VCardAPDU *ap= du, >> } >> } >> } else { >> - status =3D vcard_emul_login(card, apdu->a_body, apd= u->a_Lc); >> + status =3D vcard_emul_login(card, apdu->a_body, apdu->a= _Lc); >> *response =3D vcard_make_response(status); >> } >> } --=20 Marc-Andr=C3=A9 Lureau