ITS#10410 lutil_strncopy: fix off by one

This commit is contained in:
Howard Chu 2025-12-01 15:18:54 +00:00 committed by Quanah Gibson-Mount
parent bbc0d51bf8
commit ac34db77e2

View file

@ -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