fix backwards conditional in stpncpy
authorRich Felker <dalias@aerifal.cx>
Thu, 24 Feb 2011 17:34:31 +0000 (12:34 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 24 Feb 2011 17:34:31 +0000 (12:34 -0500)
this only made the function unnecessarily slow on systems with
unaligned access, but would of course crash on systems that can't do
unaligned accesses (none of which have ports yet).

src/string/stpncpy.c

index a877f5f..473db17 100644 (file)
@@ -14,7 +14,7 @@ char *__stpncpy(char *d, const char *s, size_t n)
        size_t *wd;
        const size_t *ws;
 
-       if (((uintptr_t)s & ALIGN) != ((uintptr_t)d & ALIGN)) {
+       if (((uintptr_t)s & ALIGN) == ((uintptr_t)d & ALIGN)) {
                for (; ((uintptr_t)s & ALIGN) && n && (*d=*s); n--, s++, d++);
                if (!n || !*s) goto tail;
                wd=(void *)d; ws=(const void *)s;