]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.1.0650: Coverity warning in cstrncmp() v9.1.0650
authorzeertzjq <zeertzjq@outlook.com>
Thu, 1 Aug 2024 20:48:53 +0000 (22:48 +0200)
committerChristian Brabandt <cb@256bit.org>
Thu, 1 Aug 2024 20:48:53 +0000 (22:48 +0200)
commite8feaa354e685e527198093904492f67c52c2302
tree4e2d646bb269cb8618c3d49e95d0c54ff2a7a347
parentc1ed788c1b41db9b5f1ef548dc877f771f535bbe
patch 9.1.0650: Coverity warning in cstrncmp()

Problem:  Coverity warning in cstrncmp()
          (after v9.1.0645)
Solution: Change the type of n2 to int.
          (zeertzjq)

________________________________________________________________________________________________________
*** CID 1615684:  Integer handling issues  (INTEGER_OVERFLOW)
/src/regexp.c: 1757 in cstrncmp()
1751                 n1 -= mb_ptr2len(s1);
1752                 MB_PTR_ADV(p);
1753                 n2++;
1754             }
1755             // count the number of bytes to advance the same number of chars for s2
1756             p = s2;
>>>     CID 1615684:  Integer handling issues  (INTEGER_OVERFLOW)
>>>     Expression "n2--", which is equal to 18446744073709551615, where "n2" is known to be equal to 0, underflows the type that receives it, an unsigned integer 64 bits wide.
1757             while (n2-- > 0 && *p != NUL)
1758                 MB_PTR_ADV(p);
1759
1760             n2 = p - s2;
1761
1762             result = MB_STRNICMP2(s1, s2, *n, n2);

closes: #15409

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/regexp.c
src/version.c