1 /*
2 Coverity model file in order to avoid false-positive
3 */
4
5 #define NULL (void*)0
6
7 typedef unsigned char jsbytecode;
8 typedef unsigned short uint16_t;
9 typedef unsigned int uint32_t;
10 typedef unsigned int int32_t;
11 typedef unsigned char uint8_t;
12
13 static const uint16_t CHUNK_HEAD_SIZE = 8;
14
assert(bool expr)15 void assert(bool expr) {
16 if (!expr) {
17 __coverity_panic__();
18 }
19 }
20
21 #define ERREXIT(cinfo, err) __coverity_panic__();
22
MOZ_ASSUME_UNREACHABLE(char * str)23 void MOZ_ASSUME_UNREACHABLE(char* str) { __coverity_panic__(); }
24
MOZ_ReportAssertionFailure(const char * aStr,const char * aFilename,int aLine)25 static void MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename,
26 int aLine) {
27 __coverity_panic__();
28 }
29
MOZ_ReportCrash(const char * aStr,const char * aFilename,int aLine)30 static void MOZ_ReportCrash(const char* aStr, const char* aFilename,
31 int aLine) {
32 __coverity_panic__();
33 }
34
35 #define MOZ_ASSERT(expr, msg) assert(!!(expr))
36
37 #define MOZ_ASSERT(expr) assert(!!(expr))
38
39 #define NS_ASSERTION(expr, msg) assert(!!(expr))
40
41 #define PORT_Assert(expr) assert(!!(expr))
42
43 #define PR_ASSERT(expr) assert(!!(expr))
44
45 #define NS_PRECONDITION(expr, msg) assert(!!(expr))
46
47 // Kills Structurally dead code (UNREACHABLE)
48 #define NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(_class) \
49 NS_IMETHODIMP_(bool) \
50 NS_CYCLE_COLLECTION_CLASSNAME(_class)::CanSkipThisReal(void* p) { \
51 __coverity_panic__(); \
52 _class* tmp = DowncastCCParticipant<_class>(p);
53
GET_JUMP_OFFSET(jsbytecode * pc)54 int GET_JUMP_OFFSET(jsbytecode* pc) {
55 __coverity_tainted_data_sink__(static_cast<void*>(pc));
56 return 0;
57 }
58
59 // Data sanity checkers
60 #define XPT_SWAB16(data) __coverity_tainted_data_sanitize__(&data)
61
62 #define XPT_SWAB32(data) __coverity_tainted_data_sanitize__(&data)
63
GET_UINT24(const jsbytecode * pc)64 static unsigned GET_UINT24(const jsbytecode* pc) {
65 __coverity_tainted_data_sink__(static_cast<void*>(pc));
66 return 0;
67 }
68
69 class HeaderParser {
70 private:
71 class ChunkHeader {
72 uint8_t mRaw[CHUNK_HEAD_SIZE];
73
ChunkSize() const74 HeaderParser::ChunkHeader::ChunkSize() const {
75 __coverity_tainted_data_sink__(static_cast<void*>(mRaw));
76 return ((mRaw[7] << 24) | (mRaw[6] << 16) | (mRaw[5] << 8) | (mRaw[4]));
77 }
78 };
79 };
80
NS_DebugBreak(uint32_t aSeverity,const char * aStr,const char * aExpr,const char * aFile,int32_t aLine)81 void NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
82 const char* aFile, int32_t aLine) {
83 __coverity_panic__();
84 }
85
Swap(uint32_t * value)86 static inline void Swap(uint32_t* value) {
87 __coverity_tainted_data_sink__(value);
88 *value = (*value >> 24) | ((*value >> 8) & 0x0000ff00) |
89 ((*value << 8) & 0x00ff0000) | (*value << 24);
90 }
91
xtolong(const uint8_t * ll)92 static uint32_t xtolong(const uint8_t* ll) {
93 uint32_t value = 0;
94 __coverity_tainted_data_sink__(static_cast<void*>(ll));
95 return value;
96 }
97
98 class ByteReader {
99 public:
100 const uint8_t* Read(size_t aCount);
ReadU24()101 uint32_t ReadU24() {
102 const uint8_t* ptr = Read(3);
103 if (!ptr) {
104 MOZ_ASSERT(false);
105 return 0;
106 }
107 __coverity_tainted_data_sanitize__(static_cast<void*>(&ptr[0]));
108 __coverity_tainted_data_sanitize__(static_cast<void*>(&ptr[1]));
109 __coverity_tainted_data_sanitize__(static_cast<void*>(&ptr[2]));
110 return ptr[0] << 16 | ptr[1] << 8 | ptr[2];
111 }
112 };
113