diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2018-10-11 17:11:29 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-11-08 19:58:00 +0100 |
commit | 2af6e52259bfd0cc7711aefbc20ce45fa90f788d (patch) | |
tree | 74e4cc5247af52ca185462543620cca37955936e | |
parent | 79578efd19c3e741945de299af32451cd5985ad1 (diff) | |
download | cmocka-2af6e52259bfd0cc7711aefbc20ce45fa90f788d.tar.gz cmocka-2af6e52259bfd0cc7711aefbc20ce45fa90f788d.tar.xz cmocka-2af6e52259bfd0cc7711aefbc20ce45fa90f788d.zip |
coverity: Fix assert model
-rw-r--r-- | coverity/coverity_assert_model.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/coverity/coverity_assert_model.c b/coverity/coverity_assert_model.c index 76baeab..7ff64d8 100644 --- a/coverity/coverity_assert_model.c +++ b/coverity/coverity_assert_model.c @@ -43,9 +43,15 @@ void _assert_return_code(const LargestIntegralType result, void _assert_string_equal(const char * const a, const char * const b, const char * const file, const int line) { + char ch; int cmp; - cmp = __coverity_strcmp(a, b); + __coverity_weak_guard_sink__(a, b); + __coverity_weak_guard_sink__(b, a); + + ch = *((char *)a); + ch = *((char *)b); + if (cmp != 0) { __coverity_panic__(); } @@ -54,9 +60,15 @@ void _assert_string_equal(const char * const a, const char * const b, void _assert_string_not_equal(const char * const a, const char * const b, const char *file, const int line) { + char ch; int cmp; - cmp = __coverity_strcmp(a, b); + __coverity_weak_guard_sink__(a, b); + __coverity_weak_guard_sink__(b, a); + + ch = *((char *)a); + ch = *((char *)b); + if (cmp == 0) { __coverity_panic__(); } @@ -66,9 +78,15 @@ void _assert_memory_equal(const void * const a, const void * const b, const size_t size, const char* const file, const int line) { + unsigned char ch; int cmp; - cmp = memcmp(a, b, size); + __coverity_weak_guard_sink__(a, b); + __coverity_weak_guard_sink__(b, a); + + ch = *((unsigned char *)a); + ch = *((unsigned char *)b); + if (cmp != 0) { __coverity_panic__(); } @@ -78,9 +96,15 @@ void _assert_memory_not_equal(const void * const a, const void * const b, const size_t size, const char* const file, const int line) { + unsigned char ch; int cmp; - cmp = memcmp(a, b, size); + __coverity_weak_guard_sink__(a, b); + __coverity_weak_guard_sink__(b, a); + + ch = *((unsigned char *)a); + ch = *((unsigned char *)b); + if (cmp == 0) { __coverity_panic__(); } @@ -108,9 +132,9 @@ void _assert_in_set( const LargestIntegralType value, const LargestIntegralType values[], const size_t number_of_values, const char* const file, const int line) { - int i; + size_t i; - if (i = 0; i < number_of_values; i++) { + for (i = 0; i < number_of_values; i++) { if (value == values[i]) { return; } @@ -122,9 +146,9 @@ void _assert_not_in_set( const LargestIntegralType value, const LargestIntegralType values[], const size_t number_of_values, const char* const file, const int line) { - int i; + size_t i; - if (i = 0; i < number_of_values; i++) { + for (i = 0; i < number_of_values; i++) { if (value == values[i]) { __coverity_panic__(); } |