src/java.naming/share/classes/com/sun/jndi/ldap/BerDecoder.java

Print this page

        

@@ -184,16 +184,20 @@
       *<blockquote><pre>
       * BER integer ::= tag length byte {byte}*
       *</pre></blockquote>
       */
     private int parseIntWithTag(int tag) throws DecodeException {
-
-
         if (parseByte() != tag) {
+            // Ber could have been reset;
+            String s;
+            if (offset > 0) {
+                s = Integer.toString(buf[offset - 1] & 0xff);
+            } else {
+                s = "Empty tag";
+            }
             throw new DecodeException("Encountered ASN.1 tag " +
-                Integer.toString(buf[offset - 1] & 0xff) +
-                " (expected tag " + Integer.toString(tag) + ")");
+                s + " (expected tag " + Integer.toString(tag) + ")");
         }
 
         int len = parseLength();
 
         if (len > 4) {