MCPcopy Index your code
hub / github.com/apache/tomcat / parseLength

Method parseLength

java/org/apache/tomcat/util/buf/Asn1Parser.java:160–192  ·  view source on GitHub ↗

Parses an ASN.1 length field. @return the parsed length value

()

Source from the content-addressed store, hash-verified

158 * @return the parsed length value
159 */
160 public int parseLength() {
161 int len = next();
162 if (len > 127) {
163 int bytes = len - 128;
164 if (bytes > 4) {
165 throw new IllegalArgumentException(sm.getString("asn1Parser.lengthInvalid", Integer.valueOf(-1),
166 Integer.valueOf(source.length - pos)));
167 }
168 len = 0;
169 for (int i = 0; i < bytes; i++) {
170 len = len << 8;
171 len = len + next();
172 }
173 if (len < 0) {
174 throw new IllegalArgumentException(sm.getString("asn1Parser.lengthInvalid", Integer.valueOf(-1),
175 Integer.valueOf(source.length - pos)));
176 }
177 }
178 /*
179 * If this is the first length parsed after a sequence has been added to the sequence nesting tracking mechanism
180 * it must be the length of the sequence so update the entry to record the end position of the sequence. Note
181 * that position recorded is actually the start of the first element after the sequence ends.
182 */
183 if (nestedSequenceEndPositions.peekLast() != null && nestedSequenceEndPositions.peekLast().intValue() == -1) {
184 nestedSequenceEndPositions.pollLast();
185 if (source.length - pos < len) {
186 throw new IllegalArgumentException(sm.getString("asn1Parser.lengthInvalid", Integer.valueOf(-1),
187 Integer.valueOf(source.length - pos)));
188 }
189 nestedSequenceEndPositions.addLast(Integer.valueOf(pos + len));
190 }
191 return len;
192 }
193
194
195 /**

Callers 5

toPrivateKeyMethod · 0.95
rfc5915ToPkcs8Method · 0.95
parseFullLengthMethod · 0.95
parseBytesMethod · 0.95
parseOCSPURLsMethod · 0.80

Calls 6

nextMethod · 0.95
peekLastMethod · 0.80
pollLastMethod · 0.80
addLastMethod · 0.80
getStringMethod · 0.65
valueOfMethod · 0.45

Tested by

no test coverage detected