Avoid accessing Uninitialized scalar variable

regression of c581d1b26

coverity scan CID 367545
This commit is contained in:
Frank Morgner 2021-03-22 13:50:50 +01:00 committed by Jakub Jelen
parent 7114fb71b5
commit ce0d409205
1 changed files with 5 additions and 4 deletions

View File

@ -2183,10 +2183,11 @@ static int do_asn1(int argc, char **argv)
}
/* workaround when the issuer of a card does prefix the EF.ATR payload with 0x80 */
if ((offsu == 0) && /* do not apply the workaround if any offset */
(buf[0] == ISO7816_II_CATEGORY_TLV) &&
(path.len >= 4) &&
(memcmp(path.value, "\x3f\x00\x2f\x01", 4) == 0))
if (offsu == 0 /* do not apply the workaround if any offset */
&& r >= 1
&& buf[0] == ISO7816_II_CATEGORY_TLV
&& path.len >= 4
&& memcmp(path.value, "\x3f\x00\x2f\x01", 4) == 0)
offs++;
/* if offset does not exceed the length read from file/record, ... */
if (offs <= (unsigned int) r) {