[hackers] [scc] [libc] Fix strncpy() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 16 Feb 2017 22:53:26 +0100 (CET)

commit 4e10af7b640ed86d32998b662f132cc76743b5db
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Feb 16 22:52:31 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 16 22:52:31 2017 +0100

    [libc] Fix strncpy()
    
    The count must be decremented in the first stage too.

diff --git a/libc/src/strncpy.c b/libc/src/strncpy.c
index 0670c6a..af3b41b 100644
--- a/libc/src/strncpy.c
+++ b/libc/src/strncpy.c
_AT_@ -7,7 +7,7 @@ strncpy(char *dst, const char *src, size_t n)
 {
         char *ret = dst;
 
- while (n > 0 && (*dst++ = *src++))
+ while (n-- > 0 && (*dst++ = *src++))
                 /* nothing */;
         while (n-- > 0)
                 *dst++ = '\0';
Received on Thu Feb 16 2017 - 22:53:26 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 16 2017 - 23:00:31 CET