Explorar o código

fix wcsncpy writing past end of buffer

Rich Felker %!s(int64=14) %!d(string=hai) anos
pai
achega
e98136207a
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/string/wcsncpy.c

+ 1 - 1
src/string/wcsncpy.c

@@ -3,7 +3,7 @@
 wchar_t *wcsncpy(wchar_t *d, const wchar_t *s, size_t n)
 {
 	wchar_t *a = d;
-	while (n && (*d++ = *s++)) n--;
+	for (; n && (*d = *s); n--, d++, s++);
 	wmemset(d, 0, n);
 	return a;
 }