mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-02-18 18:18:06 -05:00
ITS#10410 lutil_strncopy: fix off by one
This commit is contained in:
parent
bbc0d51bf8
commit
ac34db77e2
1 changed files with 4 additions and 2 deletions
|
|
@ -399,8 +399,10 @@ lutil_strncopy(
|
|||
if (!a || !b || n == 0)
|
||||
return a;
|
||||
|
||||
while ((*a++ = *b++) && n-- > 0) ;
|
||||
return a-1;
|
||||
while ((*a++ = *b++) && --n > 0) ;
|
||||
if (n)
|
||||
a--;
|
||||
return a;
|
||||
}
|
||||
|
||||
/* memcopy is like memcpy except it returns a pointer to the byte past
|
||||
|
|
|
|||
Loading…
Reference in a new issue