mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-23 13:19:55 +00:00
Fix potential buffer overflow
Under certain circumstances, it would be possible for a too-large number sent cause a buffer overflow by passing a too-large endpos.
This commit is contained in:
@@ -312,6 +312,7 @@ proc matchImpl(str: string, pattern: Regex, start, endpos: int, flags: int): Opt
|
||||
result.pcreMatchBounds.setLen(vecsize div 3)
|
||||
|
||||
let strlen = if endpos == int.high: str.len else: endpos+1
|
||||
doAssert(strlen <= str.len) # don't want buffer overflows
|
||||
|
||||
let execRet = pcre.exec(pattern.pcreObj,
|
||||
pattern.pcreExtra,
|
||||
|
||||
Reference in New Issue
Block a user