about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm/tools/win_api.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/miasm/tools/win_api.py b/miasm/tools/win_api.py
index 43ca5fe4..78ced998 100644
--- a/miasm/tools/win_api.py
+++ b/miasm/tools/win_api.py
@@ -176,7 +176,7 @@ class mdl:
 def get_str_ansi(ad_str, max_char = None):
     l = 0
     tmp = ad_str
-    while vm_get_str(tmp, 1) != "\x00":
+    while l < max_char and vm_get_str(tmp, 1) != "\x00":
         tmp +=1
         l+=1
     return vm_get_str(ad_str, l)
@@ -184,7 +184,7 @@ def get_str_ansi(ad_str, max_char = None):
 def get_str_unic(ad_str, max_char = None):
     l = 0
     tmp = ad_str
-    while vm_get_str(tmp, 2) != "\x00\x00":
+    while l < max_char and vm_get_str(tmp, 2) != "\x00\x00":
         tmp +=2
         l+=2
     return vm_get_str(ad_str, l)