kern/141682: [libc] [patch] Faster version of strncpy(3)

Maxim Zakharov maxime at maxime.net.ru
Fri Jan 15 22:30:04 UTC 2010


The following reply was made to PR kern/141682; it has been noted by GNATS.

From: Maxim Zakharov <maxime at maxime.net.ru>
To: Jaakko Heinonen <jh at freebsd.org>
Cc: bug-followup at freebsd.org
Subject: Re: kern/141682: [libc] [patch] Faster version of strncpy(3)
Date: Sat, 16 Jan 2010 01:26:03 +0300

 Hi,
 
     if (length) {
       register size_t n = length / 8;
       register size_t r = (length % 8);
       register char *dst = dst0, *src = src0;
       if (r == 0) r = 8; else n++;
 
 this solves the problem.
 
 Thank you.
 
 On 1/15/10, Jaakko Heinonen <jh at freebsd.org> wrote:
 >
 > Hi,
 >
 > On 2009-12-17, Maxim Zakharov wrote:
 >>  void * dps_strncpy(char *dst0, char *src0, size_t length) {
 >>    if (length) {
 >>      register size_t n = (length + 7) / 8;
 >
 > This won't work with length values larger than SIZE_MAX - 7 due to
 > integer overflow.
 >
 > --
 > Jaakko
 >
 
 
 -- 
 http://www.dataparksearch.org/


More information about the freebsd-bugs mailing list