summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-02-15 09:41:08 +0100
committerPatrick Steinhardt <ps@pks.im>2016-02-18 20:50:33 +0100
commit5981ab1d7050143f97636ad0ce786f01cc8b6035 (patch)
tree86c19f15afc56d8275363c868170a70a3cf0302d
parentc1b75f05ad48e9366e4503d5e392b840127f817f (diff)
downloadlibgit2-5981ab1d7050143f97636ad0ce786f01cc8b6035.tar.gz
coverity: add nodefs for abort macros
Add nodefs for macros that abort the current flow due to errors. This includes macros that trigger on integer overflows and for the version check macro. This aids Coverity as we point out that these paths will cause a fatal error.
-rw-r--r--script/user_nodefs.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/script/user_nodefs.h b/script/user_nodefs.h
index 110f76851..f890511f4 100644
--- a/script/user_nodefs.h
+++ b/script/user_nodefs.h
@@ -6,3 +6,20 @@
*/
#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__(); }