about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2017-05-09 13:46:49 +0200
committerAjax <commial@gmail.com>2017-05-09 15:19:57 +0200
commit72a446decb00be032f4f80c729b01469ce955e94 (patch)
treecb0d073bde20fc325097beaa8e09c383f912b901
parent03063d96a950101a9fdf5a4c42eec81450b5c4b7 (diff)
downloadmiasm-72a446decb00be032f4f80c729b01469ce955e94.tar.gz
miasm-72a446decb00be032f4f80c729b01469ce955e94.zip
Fix strcpyn behavior at limit
-rw-r--r--miasm2/os_dep/win_api_x86_32.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/miasm2/os_dep/win_api_x86_32.py b/miasm2/os_dep/win_api_x86_32.py
index d9c659d3..b223fa89 100644
--- a/miasm2/os_dep/win_api_x86_32.py
+++ b/miasm2/os_dep/win_api_x86_32.py
@@ -1418,8 +1418,10 @@ def kernel32_lstrcpyn(jitter):
     ret_ad, args = jitter.func_args_stdcall(["ptr_str1", "ptr_str2",
                                              "mlen"])
     s2 = jitter.get_str_ansi(args.ptr_str2)
-    s2 = s2[:args.mlen]
-    jitter.vm.set_mem(args.ptr_str1, s2)
+    if len(s2) >= args.mlen:
+        s2 = s2[:args.mlen - 1]
+    log.info("Copy '%r'", s2)
+    jitter.set_str_ansi(args.ptr_str1, s2)
     jitter.func_ret_stdcall(ret_ad, args.ptr_str1)