https://bugs.kde.org/show_bug.cgi?id=401284

--- Comment #3 from AL <l...@ncbi.nlm.nih.gov> ---
My point was that strncat() will never even encounter the terminating '\0' byte
in the source string because its counter (5) will be depleted to 0 before then
(or, in a generic case, the '\0' would have been encountered in the source
string earlier -- causing strncat() to return).  Which means that technically
the pointers used in such an operation will have never crossed the paths of
each other (in this case, the source pointer will never be used to extract
anything that goes into the area where the destination pointer was operating).

If strncat() was used in the opposite direction (vs. what's my test case's
doing), that is, trying to double the string by prepending the original string,
then the warning would be warranted, because the first position of the source
string could have been indeed overwritten:

strncat(buf, buf + len, len);

And obviously the result would have been wrong as well -- no string doubled on
the program output.

I still consider that warning as excessive in the reported case.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to