Staging
v0.5.1
https://github.com/python/cpython
Revision b7cfda132406bd0a4f626610657fd9b1e0e63f65 authored by Matthias Klose on 12 November 2008, 07:21:52 UTC, committed by Matthias Klose on 12 November 2008, 07:21:52 UTC
  parameter but was not verifying that it was greater than zero.  Values
  less than zero will now raise a SystemError and return NULL to indicate a
  bug in the calling C code. CVE-2008-1887.

  backport r62261, r62271
1 parent 8af5d57
Raw File
Tip revision: b7cfda132406bd0a4f626610657fd9b1e0e63f65 authored by Matthias Klose on 12 November 2008, 07:21:52 UTC
- Issue #2587: In the C API, PyString_FromStringAndSize() takes a signed size
Tip revision: b7cfda1
memmove.c

/* A perhaps slow but I hope correct implementation of memmove */

extern char *memcpy(char *, char *, int);

char *
memmove(char *dst, char *src, int n)
{
	char *realdst = dst;
	if (n <= 0)
		return dst;
	if (src >= dst+n || dst >= src+n)
		return memcpy(dst, src, n);
	if (src > dst) {
		while (--n >= 0)
			*dst++ = *src++;
	}
	else if (src < dst) {
		src += n;
		dst += n;
		while (--n >= 0)
			*--dst = *--src;
	}
	return realdst;
}
back to top