bump product version to 7.6.3.2-android
[LibreOffice.git] / external / firebird / ubsan.patch
blobfa296108d3d6623dbaf9af9cf73665f4432c7f3a
1 --- configure
2 +++ configure
3 @@ -21506,7 +21468,7 @@
4 char a;
5 union { long long x; sem_t y; } b;
6 };
7 - exit((int)&((struct s*)0)->b);
8 + exit((int)&((struct s*)1024)->b - 1024);
10 _ACEOF
11 if ac_fn_c_try_run "$LINENO"; then :
12 @@ -21541,7 +21503,7 @@
13 char a;
14 double b;
16 - exit((int)&((struct s*)0)->b);
17 + exit((int)&((struct s*)1024)->b - 1024);
19 _ACEOF
20 if ac_fn_c_try_run "$LINENO"; then :
21 --- src/common/classes/array.h
22 +++ src/common/classes/array.h
23 @@ -149,7 +149,7 @@
24 void copyFrom(const Array<T, Storage>& source)
26 ensureCapacity(source.count, false);
27 - memcpy(data, source.data, sizeof(T) * source.count);
28 + if (source.count != 0) memcpy(data, source.data, sizeof(T) * source.count);
29 count = source.count;
32 @@ -227,7 +227,7 @@
33 fb_assert(count <= FB_MAX_SIZEOF - itemsCount);
34 ensureCapacity(count + itemsCount);
35 memmove(data + index + itemsCount, data + index, sizeof(T) * (count - index));
36 - memcpy(data + index, items, sizeof(T) * itemsCount);
37 + if (itemsCount != 0) memcpy(data + index, items, sizeof(T) * itemsCount);
38 count += itemsCount;
41 @@ -242,7 +242,7 @@
43 fb_assert(count <= FB_MAX_SIZEOF - itemsCount);
44 ensureCapacity(count + itemsCount);
45 - memcpy(data + count, items, sizeof(T) * itemsCount);
46 + if (itemsCount != 0) memcpy(data + count, items, sizeof(T) * itemsCount);
47 count += itemsCount;
50 @@ -294,7 +294,7 @@
52 fb_assert(newCount >= count);
53 ensureCapacity(newCount);
54 - memset(data + count, 0, sizeof(T) * (newCount - count));
55 + if (newCount != count) memset(data + count, 0, sizeof(T) * (newCount - count));
56 count = newCount;
59 @@ -328,7 +328,7 @@
61 fb_assert(count <= FB_MAX_SIZEOF - L.count);
62 ensureCapacity(count + L.count);
63 - memcpy(data + count, L.data, sizeof(T) * L.count);
64 + if (L.count != 0) memcpy(data + count, L.data, sizeof(T) * L.count);
65 count += L.count;
68 @@ -462,7 +462,7 @@
70 T* newdata = static_cast<T*>
71 (this->getPool().allocate(sizeof(T) * newcapacity ALLOC_ARGS));
72 - if (preserve)
73 + if (preserve && count != 0)
74 memcpy(newdata, data, sizeof(T) * count);
75 freeData();
76 data = newdata;
77 --- src/common/classes/fb_string.h
78 +++ src/common/classes/fb_string.h
79 @@ -674,7 +674,8 @@
81 StringType& assign(const void* s, size_type n)
83 - memcpy(baseAssign(n), s, n);
84 + auto const p = baseAssign(n);
85 + if (n != 0) memcpy(p, s, n);
86 return *this;
88 StringType& assign(const_pointer s)
89 --- src/common/common.h
90 +++ src/common/common.h
91 @@ -1002,6 +1002,5 @@
94 #undef UCHAR_TYPE
95 -#define UCHAR_TYPE uint16_t
97 #endif /* COMMON_COMMON_H */
98 --- src/common/unicode_util.cpp
99 +++ src/common/unicode_util.cpp
100 @@ -187,7 +187,7 @@
101 Mutex ciAiTransCacheMutex;
102 Array<UTransliterator*> ciAiTransCache;
104 - void (U_EXPORT2 *uVersionToString)(UVersionInfo versionArray, char* versionString);
105 + void (U_EXPORT2 *uVersionToString)(UVersionInfo const versionArray, char* versionString);
107 int32_t (U_EXPORT2 *ulocCountAvailable)();
108 const char* (U_EXPORT2 *ulocGetAvailable)(int32_t n);
109 --- src/dsql/StmtNodes.cpp
110 +++ src/dsql/StmtNodes.cpp
111 @@ -6643,7 +6643,7 @@
113 void StoreNode::genBlr(DsqlCompilerScratch* dsqlScratch)
115 - const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, dsqlRse->as<RseNode>());
116 + const dsql_msg* message = dsqlGenDmlHeader(dsqlScratch, dsqlRse == nullptr ? nullptr : dsqlRse->as<RseNode>());
118 dsqlScratch->appendUChar(statement2 ? blr_store2 : blr_store);
119 GEN_expr(dsqlScratch, dsqlRelation);
120 --- src/gpre/hsh.cpp
121 +++ src/gpre/hsh.cpp
122 @@ -232,7 +232,7 @@
124 SCHAR c;
126 - SLONG value = 0;
127 + ULONG value = 0;
129 while (c = *string++)
130 value = (value << 1) + UPPER(c);
131 --- src/jrd/GlobalRWLock.cpp
132 +++ src/jrd/GlobalRWLock.cpp
133 @@ -78,7 +78,7 @@
135 cachedLock = FB_NEW_RPT(getPool(), lockLen)
136 Lock(tdbb, lockLen, lckType, this, lockCaching ? blocking_ast_cached_lock : NULL);
137 - memcpy(cachedLock->getKeyString(), lockStr, lockLen);
138 + if (lockLen != 0) memcpy(cachedLock->getKeyString(), lockStr, lockLen);
141 GlobalRWLock::~GlobalRWLock()
142 --- src/jrd/Optimizer.cpp
143 +++ src/jrd/Optimizer.cpp
144 @@ -368,7 +368,7 @@
146 // Allocate needed indexScratches
148 - index_desc* idx = csb_tail->csb_idx->items;
149 + index_desc* idx = csb_tail->csb_idx == nullptr ? nullptr : csb_tail->csb_idx->items;
150 for (int i = 0; i < csb_tail->csb_indices; ++i, ++idx)
151 indexScratches.add(IndexScratch(p, tdbb, idx, csb_tail));
153 --- src/jrd/blb.cpp
154 +++ src/jrd/blb.cpp
155 @@ -1786,7 +1786,7 @@
156 arg.slice_base = array->arr_data;
158 SLONG variables[64];
159 - memcpy(variables, param, MIN(sizeof(variables), param_length));
160 + if (param_length != 0) memcpy(variables, param, MIN(sizeof(variables), param_length));
162 if (SDL_walk(tdbb->tdbb_status_vector, sdl, array->arr_data, &array_desc->arr_desc,
163 variables, slice_callback, &arg))
164 --- src/jrd/btn.cpp
165 +++ src/jrd/btn.cpp
166 @@ -387,7 +387,7 @@
168 put_short(pagePointer, offset);
169 pagePointer += sizeof(USHORT);
170 - memmove(pagePointer, data, length);
171 + if (length != 0) memmove(pagePointer, data, length);
172 pagePointer += length;
173 return pagePointer;
175 @@ -622,7 +622,7 @@
178 // Store data
179 - if (withData) {
180 + if (withData && length != 0) {
181 memcpy(pagePointer, data, length);
183 pagePointer += length;
184 --- src/jrd/btr.cpp
185 +++ src/jrd/btr.cpp
186 @@ -5206,7 +5206,7 @@
187 // Push node on end in list
188 jumpNodes->add(jumpNode);
189 // Store new data in jumpKey, so a new jump node can calculate prefix
190 - memcpy(jumpData + jumpNode.prefix, jumpNode.data, jumpNode.length);
191 + if (jumpNode.length != 0) memcpy(jumpData + jumpNode.prefix, jumpNode.data, jumpNode.length);
192 jumpLength = jumpNode.length + jumpNode.prefix;
194 // Check if this could be our split point (if we need to split)
195 @@ -5391,7 +5391,7 @@
196 // First, store needed data for beforeInsertNode into tempData.
197 HalfStaticArray<UCHAR, MAX_KEY> tempBuf;
198 UCHAR* tempData = tempBuf.getBuffer(newLength);
199 - memcpy(tempData, beforeInsertNode.data + newPrefix - beforeInsertNode.prefix, newLength);
200 + if (newLength != 0) memcpy(tempData, beforeInsertNode.data + newPrefix - beforeInsertNode.prefix, newLength);
202 beforeInsertNode.prefix = newPrefix;
203 beforeInsertNode.length = newLength;
204 @@ -5611,7 +5611,7 @@
205 for (size_t i = 0; i < jumpNodes->getCount(); i++, index++)
207 UCHAR* q = new_key->key_data + walkJumpNode[i].prefix;
208 - memcpy(q, walkJumpNode[i].data, walkJumpNode[i].length);
209 + if (walkJumpNode[i].length != 0) memcpy(q, walkJumpNode[i].data, walkJumpNode[i].length);
210 if (index == splitJumpNodeIndex)
212 jn = &walkJumpNode[i];
213 @@ -5636,7 +5636,7 @@
214 const USHORT length = walkJumpNode[i].prefix + walkJumpNode[i].length;
215 UCHAR* newData = FB_NEW_POOL(*tdbb->getDefaultPool()) UCHAR[length];
216 memcpy(newData, new_key->key_data, walkJumpNode[i].prefix);
217 - memcpy(newData + walkJumpNode[i].prefix, walkJumpNode[i].data,
218 + if (walkJumpNode[i].length != 0) memcpy(newData + walkJumpNode[i].prefix, walkJumpNode[i].data,
219 walkJumpNode[i].length);
220 delete[] walkJumpNode[i].data;
221 walkJumpNode[i].prefix = 0;
222 --- src/jrd/evl.cpp
223 +++ src/jrd/evl.cpp
224 @@ -415,7 +415,7 @@
225 case dtype_real:
226 case dtype_sql_time:
227 case dtype_sql_date:
228 - value->vlu_misc.vlu_long = *((SLONG*) from.dsc_address);
229 + memcpy(&value->vlu_misc.vlu_long, from.dsc_address, sizeof (SLONG));
230 return;
232 case dtype_int64:
233 --- src/jrd/lck.cpp
234 +++ src/jrd/lck.cpp
235 @@ -488,7 +488,7 @@
236 break;
239 - dbb->dbb_lock_mgr->shutdownOwner(tdbb, owner_handle_ptr);
240 + LockManager::shutdownOwner(dbb->dbb_lock_mgr, tdbb, owner_handle_ptr);
244 --- src/lock/lock.cpp
245 +++ src/lock/lock.cpp
246 @@ -441,7 +441,7 @@
250 -void LockManager::shutdownOwner(thread_db* tdbb, SRQ_PTR* owner_handle)
251 +void LockManager::shutdownOwner(LockManager* This, thread_db* tdbb, SRQ_PTR* owner_handle)
253 /**************************************
255 @@ -460,8 +460,9 @@
256 if (!owner_offset)
257 return;
259 - LockTableGuard guard(this, FB_FUNCTION, owner_offset);
260 + LockTableGuard guard(This, FB_FUNCTION, owner_offset);
262 +#define SRQ_BASE ((UCHAR*) This->m_sharedMemory->getHeader())
263 own* owner = (own*) SRQ_ABS_PTR(owner_offset);
264 if (!owner->own_count)
265 return;
266 @@ -472,7 +473,7 @@
267 while (owner->own_ast_count)
269 { // checkout scope
270 - LockTableCheckout checkout(this, FB_FUNCTION);
271 + LockTableCheckout checkout(This, FB_FUNCTION);
272 EngineCheckout cout(tdbb, FB_FUNCTION, true);
273 Thread::sleep(10);
275 @@ -484,8 +485,9 @@
276 // released before destroying the lock owner. This is not strictly required,
277 // but it enforces the proper object lifetime discipline through the codebase.
278 fb_assert(SRQ_EMPTY(owner->own_requests));
279 +#define SRQ_BASE ((UCHAR*) m_sharedMemory->getHeader())
281 - purge_owner(owner_offset, owner);
282 + This->purge_owner(owner_offset, owner);
284 *owner_handle = 0;
286 --- src/lock/lock_proto.h
287 +++ src/lock/lock_proto.h
288 @@ -402,7 +402,7 @@
289 static void destroy(LockManager*);
291 bool initializeOwner(Firebird::CheckStatusWrapper*, LOCK_OWNER_T, UCHAR, SRQ_PTR*);
292 - void shutdownOwner(thread_db*, SRQ_PTR*);
293 + static void shutdownOwner(LockManager* This, thread_db*, SRQ_PTR*);
295 SRQ_PTR enqueue(thread_db*, Firebird::CheckStatusWrapper*, SRQ_PTR, const USHORT,
296 const UCHAR*, const USHORT, UCHAR, lock_ast_t, void*, SINT64, SSHORT, SRQ_PTR);
297 --- src/yvalve/gds.cpp
298 +++ src/yvalve/gds.cpp
299 @@ -2561,7 +2561,7 @@
300 value += ((SLONG) *ptr++) << shift;
301 shift += 8;
303 - value += ((SLONG)(SCHAR) *ptr) << shift;
304 + value += ((ULONG)(SCHAR) *ptr) << shift;
306 return value;