summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2013-10-25 14:28:52 +0300
committerJeff Forcier <jeff@bitprophet.org>2014-01-21 13:30:32 -0800
commitd8738b1b0f10e2f70ac69c3e3dbf10e496c8a67f (patch)
tree0d716bfd1d18dc9212fef80b68dcc68b02170fce
parent698adf10fb68330e1439b60afe9d305014395a68 (diff)
Fix #193 (use RtlMoveMemory instead of msvcrt.memcpy)
-rw-r--r--paramiko/_winapi.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/paramiko/_winapi.py b/paramiko/_winapi.py
index f141b005..9af8adde 100644
--- a/paramiko/_winapi.py
+++ b/paramiko/_winapi.py
@@ -81,9 +81,6 @@ def handle_nonzero_success(result):
raise WindowsError()
-#####################
-# jaraco.windows.mmap
-
CreateFileMapping = ctypes.windll.kernel32.CreateFileMappingW
CreateFileMapping.argtypes = [
ctypes.wintypes.HANDLE,
@@ -130,15 +127,18 @@ class MemoryMap(object):
self.pos = pos
def write(self, msg):
- ctypes.windll.msvcrt.memcpy(self.view + self.pos, msg, len(msg))
- self.pos += len(msg)
+ n = len(msg)
+ if self.pos + n >= self.length: # A little safety.
+ raise ValueError("Refusing to write %d bytes" % n)
+ ctypes.windll.kernel32.RtlMoveMemory(self.view + self.pos, msg, n)
+ self.pos += n
def read(self, n):
"""
Read n bytes from mapped view.
"""
out = ctypes.create_string_buffer(n)
- ctypes.windll.msvcrt.memcpy(out, self.view + self.pos, n)
+ ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n)
self.pos += n
return out.raw