summary refs log tree commit diff stats
path: root/src/nre.nim
diff options
context:
space:
mode:
authorFlaviu Tamas <tamasflaviu@gmail.com>2015-04-10 13:18:08 -0400
committerFlaviu Tamas <tamasflaviu@gmail.com>2015-04-10 13:18:08 -0400
commite6d662e6b96edbe61eea7d1cce43893566c28039 (patch)
tree15e200abf90b94b907574e0185207dd22bc432e7 /src/nre.nim
parenteca9597635f9ea74473ef7c21132dca9edf28e52 (diff)
downloadNim-e6d662e6b96edbe61eea7d1cce43893566c28039.tar.gz
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.
Diffstat (limited to 'src/nre.nim')
-rw-r--r--src/nre.nim1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/nre.nim b/src/nre.nim
index b601d8222..a222da6c0 100644
--- a/src/nre.nim
+++ b/src/nre.nim
@@ -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,