diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-02-15 10:58:52 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2016-02-18 20:50:33 +0100 |
commit | 40f6f225175375b41317b0a4e98e8865600d1682 (patch) | |
tree | f8a1af9b9912cb9405670946bb6c292990bd9c4a /script | |
parent | 5981ab1d7050143f97636ad0ce786f01cc8b6035 (diff) | |
download | libgit2-40f6f225175375b41317b0a4e98e8865600d1682.tar.gz |
coverity: hint that string length is at least 2
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.
Diffstat (limited to 'script')
-rw-r--r-- | script/user_nodefs.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/script/user_nodefs.h b/script/user_nodefs.h index f890511f4..3d25d92ec 100644 --- a/script/user_nodefs.h +++ b/script/user_nodefs.h @@ -23,3 +23,5 @@ 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] == ':') |