Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6474858

CardChannel.transmit(CommandAPDU) throws unexpected ArrayIndexOutOfBoundsException

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 6, 7
    • Fix Version/s: 12
    • Component/s: security-libs
    • Labels:

      Description

      Problem description:
      ====================
      Method "public abstract ResponseAPDU CardChannel.transmit(CommandAPDU command)" of Sun's implementation of "PC/SC" smartcard reader I/O engine throws unspecified ArrayIndexOutOfBoundsException in case of below command:
      {0x00, 0xA4, 0x00, 0x00}.
      This command contains a "SELECT FILE" instruction ("0xA4").
      The same behaviour has the method "public abstract int CardChannel.transmit(ByteBuffer command, ByteBuffer response)".

      Issue appears on Windows XP with Gemplus "GemPCTwin" smart card reader for serial port, but also can be reproduced on Linux with the same card reader.

      Minimized test:
      ===============
      ---test.java---
      import javax.smartcardio.*;
      public class test {

          public static void main(String[] args) {
              CommandAPDU apdu = new CommandAPDU(0x00,0xA4,0x00, 0x00);
              CardTerminals terminals = TerminalFactory.getDefault().terminals();
              try {
                  if (!terminals.list().isEmpty()) {
                      CardTerminal terminal = terminals.list().get(0);
                      
                      if(terminal.isCardPresent()) {
                          Card card = terminal.connect("*");
                          CardChannel channel = card.getBasicChannel();
                          ResponseAPDU r_apdu = channel.transmit(apdu);
                          System.out.println("Bug is absent");
                          
                      } else {
                          System.out.println("Bug cannot be reproduced: Card is"
                                  + " absent");
                      }
                      
                  } else {
                      System.out.println("Bug cannot be reproduced:There are no"
                              + " any card terminals");
                  }
              } catch(CardException e) {
                  
              }

          }
      }
      ---test.java---

      Minimized test output:
      ======================
      C:\test>javac *.java

      C:\test>java -cp ./ test
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
              at sun.security.smartcardio.ChannelImpl.doTransmit(ChannelImpl.java:190)
              at sun.security.smartcardio.ChannelImpl.transmit(ChannelImpl.java:73)
              at test.main(test.java:14)

      C:\test>

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              igerasim Ivan Gerasimov
              Reporter:
              vsmelovsunw Vladimir Smelov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: