mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 22:39:38 +00:00

When checking if a string is prefixed by a drive letter (e.g. "C:") we verify this by inspecting the first and second character of the string. Coverity thinks this is a defect as we do not check the string's length first, but in fact we only check the second character if the first character is part of the alphabet, that is it cannot be '\0'. Fix this by overriding the macro and explicitly checking the string's length.
28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
/*
|
|
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
*
|
|
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
* a Linking Exception. For full terms see the included COPYING file.
|
|
*/
|
|
|
|
#nodef GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { __coverity_panic__(); }
|
|
|
|
#nodef GITERR_CHECK_ALLOC_ADD(out, one, two) \
|
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { __coverity_panic__(); }
|
|
|
|
#nodef GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
|
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
|
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { __coverity_panic__(); }
|
|
|
|
#nodef GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
|
|
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
|
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
|
|
GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { __coverity_panic__(); }
|
|
|
|
#nodef GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
|
|
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { __coverity_panic__(); }
|
|
|
|
#nodef GITERR_CHECK_VERSION(S,V,N) if (giterr__check_version(S,V,N) < 0) { __coverity_panic__(); }
|
|
|
|
#nodef LOOKS_LIKE_DRIVE_PREFIX(S) (strlen(S) >= 2 && git__isalpha((S)[0]) && (S)[1] == ':')
|