File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,9 @@ def getChildCount(self):
8585 while True :
8686 if p .getRemainingLength () == 0 :
8787 break
88- p .get (1 ) # skip Type
88+ p .skip_bytes (1 ) # skip Type
8989 length = self ._getASN1Length (p )
90- p .getFixBytes (length ) # skip value
90+ p .skip_bytes (length ) # skip value
9191 count += 1
9292 return count
9393
@@ -104,9 +104,9 @@ def getChildBytes(self, which):
104104 p = Parser (self .value )
105105 for _ in range (which + 1 ):
106106 markIndex = p .index
107- p .get (1 ) # skip Type
107+ p .skip_bytes (1 ) # skip Type
108108 length = self ._getASN1Length (p )
109- p .getFixBytes (length )
109+ p .skip_bytes (length )
110110 return p .bytes [markIndex : p .index ]
111111
112112 @staticmethod
Original file line number Diff line number Diff line change @@ -324,6 +324,12 @@ def getFixBytes(self, lengthBytes):
324324 self .index += lengthBytes
325325 return bytes
326326
327+ def skip_bytes (self , length ):
328+ """Move the internal pointer ahead length bytes."""
329+ if self .index + length > len (self .bytes ):
330+ raise DecodeError ("Read past end of buffer" )
331+ self .index += length
332+
327333 def getVarBytes (self , lengthLength ):
328334 """
329335 Read a variable length string with a fixed length.
You can’t perform that action at this time.
0 commit comments