xref: /aoo41x/main/expat/expat-2.5.0.patch (revision 9ceaae4a)
1diff -ru misc/expat-2.5.0/lib/makefile.mk misc/build/expat-2.5.0/lib/makefile.mk
2--- misc/expat-2.5.0/lib/makefile.mk	2023-02-06 23:22:07.391327553 +0100
3+++ misc/build/expat-2.5.0/lib/makefile.mk	2023-02-06 23:22:40.584115842 +0100
4@@ -1,1 +1,79 @@
5-dummy
6+#**************************************************************
7+#
8+#  Licensed to the Apache Software Foundation (ASF) under one
9+#  or more contributor license agreements.  See the NOTICE file
10+#  distributed with this work for additional information
11+#  regarding copyright ownership.  The ASF licenses this file
12+#  to you under the Apache License, Version 2.0 (the
13+#  "License"); you may not use this file except in compliance
14+#  with the License.  You may obtain a copy of the License at
15+#
16+#    http://www.apache.org/licenses/LICENSE-2.0
17+#
18+#  Unless required by applicable law or agreed to in writing,
19+#  software distributed under the License is distributed on an
20+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21+#  KIND, either express or implied.  See the License for the
22+#  specific language governing permissions and limitations
23+#  under the License.
24+#
25+#**************************************************************
26+PRJ=..$/..$/..$/..$/..
27+
28+PRJNAME=expat
29+TARGET=expat
30+LIBTARGET=NO
31+EXTERNAL_WARNINGS_NOT_ERRORS=TRUE
32+
33+# --- Settings -----------------------------------------------------
34+.INCLUDE :  settings.mk
35+# --- Files --------------------------------------------------------
36+
37+CFLAGS+=-I..
38+
39+.IF "$(OS)"=="WNT"
40+CDEFS+=-DWIN32
41+.ELSE
42+CDEFS+=-DHAVE_EXPAT_CONFIG_H
43+.ENDIF
44+
45+.IF "$(OS)"=="MACOSX" && "$(SYSBASE)"!=""
46+CDEFS+=-DHAVE_MEMMOVE -DHAVE_BCOPY
47+.ENDIF # "$(OS)"=="MACOSX"
48+
49+SECOND_BUILD=UNICODE
50+UNICODE_SLOFILES=$(SLO)$/xmlparse.obj
51+UNICODECDEFS+=-DXML_UNICODE
52+
53+LIB1ARCHIV=$(LB)$/libascii_$(TARGET)_xmlparse.a
54+LIB1TARGET=$(SLB)$/ascii_$(TARGET)_xmlparse.lib
55+LIB1OBJFILES=$(SLO)$/xmlparse.obj
56+
57+LIB2ARCHIV=$(LB)$/lib$(TARGET)_xmlparse.a
58+LIB2TARGET=$(SLB)$/$(TARGET)_xmlparse.lib
59+LIB2OBJFILES =$(REAL_UNICODE_SLOFILES)
60+
61+LIB3ARCHIV=$(LB)$/lib$(TARGET)_xmltok.a
62+LIB3TARGET=$(SLB)$/$(TARGET)_xmltok.lib
63+LIB3OBJFILES=$(SLO)$/xmlrole.obj $(SLO)$/xmltok.obj
64+
65+.IF "$(BUILD_X64)"!=""
66+# ---------------- X64 stuff special ---------------------
67+#  use UNICODE only because shell/shlxthandler
68+#  doesn't link against ascii_expat_xmlparse
69+#---------------------------------------------------------
70+SLOFILES_X64=$(SLO_X64)$/xmlparse.obj \
71+             $(SLO_X64)$/xmlrole.obj \
72+             $(SLO_X64)$/xmltok.obj
73+CDEFS_X64+=-DXML_UNICODE -DWIN32
74+CFLAGS_X64+=-I..
75+LIB1TARGET_X64=$(SLB_X64)$/$(TARGET)_xmlparse.lib
76+LIB1OBJFILES_X64=$(SLO_X64)$/xmlparse.obj
77+LIB2TARGET_X64=$(SLB_X64)$/$(TARGET)_xmltok.lib
78+LIB2OBJFILES_X64=$(SLO_X64)$/xmlrole.obj $(SLO_X64)$/xmltok.obj
79+.ENDIF # "$(BUILD_X64)"!=""
80+
81+# --- Targets ------------------------------------------------------
82+.INCLUDE :  set_wntx64.mk
83+.INCLUDE :	target.mk
84+.INCLUDE :  tg_wntx64.mk
85diff -ru misc/expat-2.5.0/Changes misc/build/expat-2.5.0/Changes
86--- misc/expat-2.5.0/Changes	2022-10-25 17:09:08.000000000 +0200
87+++ misc/build/expat-2.5.0/Changes	2023-02-06 23:22:40.572115558 +0100
88@@ -2,6 +2,9 @@
89       https://github.com/libexpat/libexpat/labels/help%20wanted
90       If you can help, please get in touch.  Thanks!
91
92+Release 2.5.0-aoo Sat February 04 2023
93+        Adapted to AOO sources.
94+
95 Release 2.5.0 Tue October 25 2022
96         Security fixes:
97   #616 #649 #650  CVE-2022-43680 -- Fix heap use-after-free after overeager
98diff -ru misc/expat-2.5.0/expat_config.h misc/build/expat-2.5.0/expat_config.h
99--- misc/expat-2.5.0/expat_config.h	2022-10-25 17:34:58.000000000 +0200
100+++ misc/build/expat-2.5.0/expat_config.h	2023-02-06 23:22:40.604116318 +0100
101@@ -14,7 +14,7 @@
102 /* #undef HAVE_ARC4RANDOM */
103
104 /* Define to 1 if you have the `arc4random_buf' function. */
105-#define HAVE_ARC4RANDOM_BUF 1
106+/* #undef HAVE_ARC4RANDOM_BUF */
107
108 /* Define to 1 if you have the <dlfcn.h> header file. */
109 #define HAVE_DLFCN_H 1
110@@ -74,13 +74,13 @@
111 #define PACKAGE "expat"
112
113 /* Define to the address where bug reports for this package should be sent. */
114-#define PACKAGE_BUGREPORT "expat-bugs@libexpat.org"
115+#define PACKAGE_BUGREPORT "dev@openoffice.apache.org"
116
117 /* Define to the full name of this package. */
118 #define PACKAGE_NAME "expat"
119
120 /* Define to the full name and version of this package. */
121-#define PACKAGE_STRING "expat 2.5.0"
122+#define PACKAGE_STRING "expat 2.5.0-aoo"
123
124 /* Define to the one symbol short name of this package. */
125 #define PACKAGE_TARNAME "expat"
126@@ -89,7 +89,7 @@
127 #define PACKAGE_URL ""
128
129 /* Define to the version of this package. */
130-#define PACKAGE_VERSION "2.5.0"
131+#define PACKAGE_VERSION "2.5.0-aoo"
132
133 /* Define to 1 if all of the C90 standard headers exist (not just the ones
134    required in a freestanding environment). This macro is provided for
135@@ -97,7 +97,7 @@
136 #define STDC_HEADERS 1
137
138 /* Version number of package */
139-#define VERSION "2.5.0"
140+#define VERSION "2.5.0-aoo"
141
142 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
143    significant byte first (like Motorola and SPARC, unlike Intel). */
144@@ -119,8 +119,10 @@
145    point. */
146 #define XML_CONTEXT_BYTES 1024
147
148+#if ! defined(_WIN32)
149 /* Define to include code reading entropy from `/dev/urandom'. */
150 #define XML_DEV_URANDOM 1
151+#endif
152
153 /* Define to make parameter entity parsing functionality available. */
154 #define XML_DTD 1
155@@ -128,6 +130,11 @@
156 /* Define to make XML Namespaces functionality available. */
157 #define XML_NS 1
158
159+/* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */
160+#ifdef _MSC_VER
161+#  define __func__ __FUNCTION__
162+#endif
163+
164 /* Define to empty if `const' does not conform to ANSI C. */
165 /* #undef const */
166
167diff -ru misc/expat-2.5.0/lib/siphash.h misc/build/expat-2.5.0/lib/siphash.h
168--- misc/expat-2.5.0/lib/siphash.h	2022-10-23 17:16:56.000000000 +0200
169+++ misc/build/expat-2.5.0/lib/siphash.h	2023-02-06 23:22:40.588115938 +0100
170@@ -99,7 +99,15 @@
171 #define SIPHASH_H
172
173 #include <stddef.h> /* size_t */
174-#include <stdint.h> /* uint64_t uint32_t uint8_t */
175+#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
176+/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */
177+typedef unsigned __int8 uint8_t;
178+typedef unsigned __int32 uint32_t;
179+typedef unsigned __int64 uint64_t;
180+#else
181+#  include <stdint.h> /* uint64_t uint32_t uint8_t */
182+#endif
183+
184
185 /*
186  * Workaround to not require a C++11 compiler for using ULL suffix
187diff -ru misc/expat-2.5.0/lib/winconfig.h misc/build/expat-2.5.0/lib/winconfig.h
188--- misc/expat-2.5.0/lib/winconfig.h	2022-10-24 18:32:55.000000000 +0200
189+++ misc/build/expat-2.5.0/lib/winconfig.h	2023-02-06 23:22:40.584115842 +0100
190@@ -42,4 +42,11 @@
191 #include <memory.h>
192 #include <string.h>
193
194+#  define XML_NS 1
195+#  define XML_DTD 1
196+#  define XML_CONTEXT_BYTES 1024
197+
198+/* we will assume all Windows platforms are little endian */
199+#  define BYTEORDER 1234
200+
201 #endif /* ndef WINCONFIG_H */
202diff -ru misc/expat-2.5.0/lib/xmlparse.c misc/build/expat-2.5.0/lib/xmlparse.c
203--- misc/expat-2.5.0/lib/xmlparse.c	2022-10-25 17:09:08.000000000 +0200
204+++ misc/build/expat-2.5.0/lib/xmlparse.c	2023-02-06 23:22:40.584115842 +0100
205@@ -60,8 +60,6 @@
206
207 #define XML_BUILDING_EXPAT 1
208
209-#include <expat_config.h>
210-
211 #if ! defined(_GNU_SOURCE)
212 #  define _GNU_SOURCE 1 /* syscall prototype */
213 #endif
214@@ -79,9 +77,19 @@
215 #include <limits.h> /* UINT_MAX */
216 #include <stdio.h>  /* fprintf */
217 #include <stdlib.h> /* getenv, rand_s */
218-#include <stdint.h> /* uintptr_t */
219 #include <math.h>   /* isnan */
220
221+#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
222+/* vs2008/9.0 and earlier lack stdint.h; _MSC_VER 1600 is vs2010/10.0 */
223+#  if defined(_WIN64)
224+typedef unsigned __int64 uintptr_t;
225+#  else
226+typedef unsigned __int32 uintptr_t;
227+#  endif
228+#else
229+#  include <stdint.h> /* uintptr_t */
230+#endif
231+
232 #ifdef _WIN32
233 #  define getpid GetCurrentProcessId
234 #else
235@@ -94,7 +102,13 @@
236
237 #ifdef _WIN32
238 #  include "winconfig.h"
239+#include <float.h>
240+#ifndef isnan
241+#define isnan _isnan
242 #endif
243+#else
244+#  include <expat_config.h>
245+#endif /* ndef _WIN32 */
246
247 #include "ascii.h"
248 #include "expat.h"
249@@ -720,7 +734,9 @@
250
251 XML_Parser XMLCALL
252 XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) {
253-  XML_Char tmp[2] = {nsSep, 0};
254+  XML_Char tmp[2];
255+  tmp[0] = nsSep;
256+  tmp[1] = 0;
257   return XML_ParserCreate_MM(encodingName, NULL, tmp);
258 }
259
260@@ -1354,7 +1370,9 @@
261      would be otherwise.
262   */
263   if (parser->m_ns) {
264-    XML_Char tmp[2] = {parser->m_namespaceSeparator, 0};
265+    XML_Char tmp[2];
266+    tmp[0] = parser->m_namespaceSeparator;
267+    tmp[1] = 0;
268     parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd);
269   } else {
270     parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd);
271@@ -3469,6 +3487,8 @@
272   i = 0;
273   if (nPrefixes) {
274     int j; /* hash table index */
275+    unsigned int nsAttsSize;
276+    unsigned char oldNsAttsPower;
277     unsigned long version = parser->m_nsAttsVersion;
278
279     /* Detect and prevent invalid shift */
280@@ -3476,8 +3496,8 @@
281       return XML_ERROR_NO_MEMORY;
282     }
283
284-    unsigned int nsAttsSize = 1u << parser->m_nsAttsPower;
285-    unsigned char oldNsAttsPower = parser->m_nsAttsPower;
286+    nsAttsSize = 1u << parser->m_nsAttsPower;
287+    oldNsAttsPower = parser->m_nsAttsPower;
288     /* size of hash table must be at least 2 * (# of prefixed attributes) */
289     if ((nPrefixes << 1)
290         >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */
291@@ -3922,6 +3942,7 @@
292   if (parser->m_freeBindingList) {
293     b = parser->m_freeBindingList;
294     if (len > b->uriAlloc) {
295+      XML_Char *temp = NULL;
296       /* Detect and prevent integer overflow */
297       if (len > INT_MAX - EXPAND_SPARE) {
298         return XML_ERROR_NO_MEMORY;
299@@ -3937,7 +3958,7 @@
300       }
301 #endif
302
303-      XML_Char *temp = (XML_Char *)REALLOC(
304+      temp = (XML_Char *)REALLOC(
305           parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
306       if (temp == NULL)
307         return XML_ERROR_NO_MEMORY;
308@@ -4638,11 +4659,6 @@
309          ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0'};
310   static const XML_Char enumValueSep[] = {ASCII_PIPE, '\0'};
311   static const XML_Char enumValueStart[] = {ASCII_LPAREN, '\0'};
312-
313-#ifndef XML_DTD
314-  UNUSED_P(account);
315-#endif
316-
317   /* save one level of indirection */
318   DTD *const dtd = parser->m_dtd;
319
320@@ -4650,6 +4666,10 @@
321   const char **eventEndPP;
322   enum XML_Content_Quant quant;
323
324+#ifndef XML_DTD
325+  UNUSED_P(account);
326+#endif
327+
328   if (enc == parser->m_encoding) {
329     eventPP = &parser->m_eventPtr;
330     eventEndPP = &parser->m_eventEndPtr;
331@@ -5290,12 +5310,13 @@
332       if (parser->m_prologState.level >= parser->m_groupSize) {
333         if (parser->m_groupSize) {
334           {
335+	    char *new_connector = NULL;
336             /* Detect and prevent integer overflow */
337             if (parser->m_groupSize > (unsigned int)(-1) / 2u) {
338               return XML_ERROR_NO_MEMORY;
339             }
340
341-            char *const new_connector = (char *)REALLOC(
342+            new_connector = (char *)REALLOC(
343                 parser, parser->m_groupConnector, parser->m_groupSize *= 2);
344             if (new_connector == NULL) {
345               parser->m_groupSize /= 2;
346@@ -5309,13 +5330,14 @@
347              * The preprocessor guard addresses the "always false" warning
348              * from -Wtype-limits on platforms where
349              * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
350+	    int *new_scaff_index = NULL;
351 #if UINT_MAX >= SIZE_MAX
352             if (parser->m_groupSize > (size_t)(-1) / sizeof(int)) {
353               return XML_ERROR_NO_MEMORY;
354             }
355 #endif
356
357-            int *const new_scaff_index = (int *)REALLOC(
358+            new_scaff_index = (int *)REALLOC(
359                 parser, dtd->scaffIndex, parser->m_groupSize * sizeof(int));
360             if (new_scaff_index == NULL)
361               return XML_ERROR_NO_MEMORY;
362@@ -6404,13 +6426,14 @@
363       }
364     } else {
365       DEFAULT_ATTRIBUTE *temp;
366+      int count;
367
368       /* Detect and prevent integer overflow */
369       if (type->allocDefaultAtts > INT_MAX / 2) {
370         return 0;
371       }
372
373-      int count = type->allocDefaultAtts * 2;
374+      count = type->allocDefaultAtts * 2;
375
376       /* Detect and prevent integer overflow.
377        * The preprocessor guard addresses the "always false" warning
378@@ -7072,22 +7095,26 @@
379     /* check for overflow (table is half full) */
380     if (table->used >> (table->power - 1)) {
381       unsigned char newPower = table->power + 1;
382+      size_t newSize;
383+      unsigned long newMask;
384+      size_t tsize;
385+      NAMED **newV = NULL;
386
387       /* Detect and prevent invalid shift */
388       if (newPower >= sizeof(unsigned long) * 8 /* bits per byte */) {
389         return NULL;
390       }
391
392-      size_t newSize = (size_t)1 << newPower;
393-      unsigned long newMask = (unsigned long)newSize - 1;
394+      newSize = (size_t)1 << newPower;
395+      newMask = (unsigned long)newSize - 1;
396
397       /* Detect and prevent integer overflow */
398       if (newSize > (size_t)(-1) / sizeof(NAMED *)) {
399         return NULL;
400       }
401
402-      size_t tsize = newSize * sizeof(NAMED *);
403-      NAMED **newV = table->mem->malloc_fcn(tsize);
404+      tsize = newSize * sizeof(NAMED *);
405+      newV = table->mem->malloc_fcn(tsize);
406       if (! newV)
407         return NULL;
408       memset(newV, 0, tsize);
409@@ -7489,6 +7516,10 @@
410   DTD *const dtd = parser->m_dtd; /* save one level of indirection */
411   XML_Content *ret;
412   XML_Char *str; /* the current string writing location */
413+  size_t allocsize;
414+  XML_Content *dest = NULL;
415+  XML_Content *destLimit = NULL;
416+  XML_Content *jobDest = NULL;
417
418   /* Detect and prevent integer overflow.
419    * The preprocessor guard addresses the "always false" warning
420@@ -7507,7 +7538,7 @@
421     return NULL;
422   }
423
424-  const size_t allocsize = (dtd->scaffCount * sizeof(XML_Content)
425+  allocsize = (dtd->scaffCount * sizeof(XML_Content)
426                             + (dtd->contentStringLen * sizeof(XML_Char)));
427
428   ret = (XML_Content *)MALLOC(parser, allocsize);
429@@ -7563,9 +7594,9 @@
430    *
431    * - The algorithm repeats until all target array indices have been processed.
432    */
433-  XML_Content *dest = ret; /* tree node writing location, moves upwards */
434-  XML_Content *const destLimit = &ret[dtd->scaffCount];
435-  XML_Content *jobDest = ret; /* next free writing location in target array */
436+  dest = ret; /* tree node writing location, moves upwards */
437+  destLimit = &ret[dtd->scaffCount];
438+  jobDest = ret; /* next free writing location in target array */
439   str = (XML_Char *)&ret[dtd->scaffCount];
440
441   /* Add the starting job, the root node (index 0) of the source tree  */
442@@ -7670,13 +7701,14 @@
443 static void
444 accountingReportStats(XML_Parser originParser, const char *epilog) {
445   const XML_Parser rootParser = getRootParserOf(originParser, NULL);
446+  float amplificationFactor;
447   assert(! rootParser->m_parentParser);
448
449   if (rootParser->m_accounting.debugLevel < 1) {
450     return;
451   }
452
453-  const float amplificationFactor
454+  amplificationFactor
455       = accountingGetCurrentAmplification(rootParser);
456   fprintf(stderr,
457           "expat: Accounting(%p): Direct " EXPAT_FMT_ULL(
458@@ -7696,6 +7728,10 @@
459                      unsigned int levelsAwayFromRootParser, const char *before,
460                      const char *after, ptrdiff_t bytesMore, int source_line,
461                      enum XML_Account account) {
462+  const char ellipis[] = "[..]";
463+  const size_t ellipsisLength = sizeof(ellipis) /* because compile-time */ - 1;
464+  const unsigned int contextLength = 10;
465+  const char *walker = NULL;
466   assert(! rootParser->m_parentParser);
467
468   fprintf(stderr,
469@@ -7703,12 +7739,8 @@
470           bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
471           levelsAwayFromRootParser, source_line, 10, "");
472
473-  const char ellipis[] = "[..]";
474-  const size_t ellipsisLength = sizeof(ellipis) /* because compile-time */ - 1;
475-  const unsigned int contextLength = 10;
476-
477   /* Note: Performance is of no concern here */
478-  const char *walker = before;
479+  walker = before;
480   if ((rootParser->m_accounting.debugLevel >= 3)
481       || (after - before)
482              <= (ptrdiff_t)(contextLength + ellipsisLength + contextLength)) {
483@@ -7732,6 +7764,14 @@
484 accountingDiffTolerated(XML_Parser originParser, int tok, const char *before,
485                         const char *after, int source_line,
486                         enum XML_Account account) {
487+  unsigned int levelsAwayFromRootParser;
488+  XML_Parser rootParser;
489+  int isDirect;
490+  ptrdiff_t bytesMore;
491+  XmlBigCount *additionTarget = NULL;
492+  XmlBigCount countBytesOutput;
493+  float amplificationFactor;
494+  XML_Bool tolerated;
495   /* Note: We need to check the token type *first* to be sure that
496    *       we can even access variable <after>, safely.
497    *       E.g. for XML_TOK_NONE <after> may hold an invalid pointer. */
498@@ -7746,16 +7786,15 @@
499   if (account == XML_ACCOUNT_NONE)
500     return XML_TRUE; /* because these bytes have been accounted for, already */
501
502-  unsigned int levelsAwayFromRootParser;
503-  const XML_Parser rootParser
504+  rootParser
505       = getRootParserOf(originParser, &levelsAwayFromRootParser);
506   assert(! rootParser->m_parentParser);
507
508-  const int isDirect
509+  isDirect
510       = (account == XML_ACCOUNT_DIRECT) && (originParser == rootParser);
511-  const ptrdiff_t bytesMore = after - before;
512+  bytesMore = after - before;
513
514-  XmlBigCount *const additionTarget
515+  additionTarget
516       = isDirect ? &rootParser->m_accounting.countBytesDirect
517                  : &rootParser->m_accounting.countBytesIndirect;
518
519@@ -7764,12 +7803,12 @@
520     return XML_FALSE;
521   *additionTarget += bytesMore;
522
523-  const XmlBigCount countBytesOutput
524+  countBytesOutput
525       = rootParser->m_accounting.countBytesDirect
526         + rootParser->m_accounting.countBytesIndirect;
527-  const float amplificationFactor
528+  amplificationFactor
529       = accountingGetCurrentAmplification(rootParser);
530-  const XML_Bool tolerated
531+  tolerated
532       = (countBytesOutput < rootParser->m_accounting.activationThresholdBytes)
533         || (amplificationFactor
534             <= rootParser->m_accounting.maximumAmplificationFactor);
535@@ -7800,14 +7839,15 @@
536 static void
537 entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
538                           const char *action, int sourceLine) {
539+  const char *entityName;
540   assert(! rootParser->m_parentParser);
541   if (rootParser->m_entity_stats.debugLevel < 1)
542     return;
543
544 #  if defined(XML_UNICODE)
545-  const char *const entityName = "[..]";
546+  entityName = "[..]";
547 #  else
548-  const char *const entityName = entity->name;
549+  entityName = entity->name;
550 #  endif
551
552   fprintf(
553@@ -8387,14 +8427,17 @@
554 static unsigned long
555 getDebugLevel(const char *variableName, unsigned long defaultDebugLevel) {
556   const char *const valueOrNull = getenv(variableName);
557+  const char *value = NULL;
558+  char *afterValue = NULL;
559+  unsigned long debugLevel;
560   if (valueOrNull == NULL) {
561     return defaultDebugLevel;
562   }
563-  const char *const value = valueOrNull;
564+  value = valueOrNull;
565
566   errno = 0;
567-  char *afterValue = (char *)value;
568-  unsigned long debugLevel = strtoul(value, &afterValue, 10);
569+  afterValue = (char *)value;
570+  debugLevel = strtoul(value, &afterValue, 10);
571   if ((errno != 0) || (afterValue[0] != '\0')) {
572     errno = 0;
573     return defaultDebugLevel;
574diff -ru misc/expat-2.5.0/lib/xmltok.c misc/build/expat-2.5.0/lib/xmltok.c
575--- misc/expat-2.5.0/lib/xmltok.c	2022-10-24 18:32:55.000000000 +0200
576+++ misc/build/expat-2.5.0/lib/xmltok.c	2023-02-06 23:22:40.588115938 +0100
577@@ -44,14 +44,22 @@
578    USE OR OTHER DEALINGS IN THE SOFTWARE.
579 */
580
581-#include <expat_config.h>
582-
583 #include <stddef.h>
584 #include <string.h> /* memcpy */
585-#include <stdbool.h>
586+
587+#if defined(_MSC_VER) && (_MSC_VER <= 1700)
588+/* for vs2012/11.0/1700 and earlier Visual Studio compilers */
589+#  define bool int
590+#  define false 0
591+#  define true 1
592+#else
593+#  include <stdbool.h>
594+#endif
595
596 #ifdef _WIN32
597 #  include "winconfig.h"
598+#else
599+#  include <expat_config.h>
600 #endif
601
602 #include "expat_external.h"
603diff -ru misc/expat-2.5.0/tests/runtests.c misc/build/expat-2.5.0/tests/runtests.c
604--- misc/expat-2.5.0/tests/runtests.c	2022-10-25 17:09:08.000000000 +0200
605+++ misc/build/expat-2.5.0/tests/runtests.c	2023-02-06 23:22:40.592116032 +0100
606@@ -40,7 +40,15 @@
607    USE OR OTHER DEALINGS IN THE SOFTWARE.
608 */
609
610-#include <expat_config.h>
611+#ifdef _WIN32
612+#  include "winconfig.h"
613+#include <float.h>
614+#ifndef isnan
615+#define isnan _isnan
616+#endif
617+#else
618+#  include <expat_config.h>
619+#endif /* ndef _WIN32 */
620
621 #if defined(NDEBUG)
622 #  undef NDEBUG /* because test suite relies on assert(...) at the moment */
623@@ -53,11 +61,28 @@
624 #include <stddef.h> /* ptrdiff_t */
625 #include <ctype.h>
626 #include <limits.h>
627-#include <stdint.h> /* intptr_t uint64_t */
628+
629+#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
630+/* vs2008/9.0 and earlier lack stdint.h; _MSC_VER 1600 is vs2010/10.0 */
631+#  if defined(_WIN64)
632+typedef unsigned __int64 uintptr_t;
633+#  else
634+typedef unsigned __int32 uintptr_t;
635+#  endif
636+#else
637+#  include <stdint.h> /* uintptr_t */
638+#endif
639
640 #if ! defined(__cplusplus)
641+#if defined(_MSC_VER) && (_MSC_VER <= 1700)
642+/* for vs2012/11.0/1700 and earlier Visual Studio compilers */
643+#  define bool int
644+#  define false 0
645+#  define true 1
646+#else
647 #  include <stdbool.h>
648 #endif
649+#endif
650
651 #include "expat.h"
652 #include "chardata.h"
653@@ -2666,8 +2691,8 @@
654 static void XMLCALL
655 element_decl_check_model(void *userData, const XML_Char *name,
656                          XML_Content *model) {
657-  UNUSED_P(userData);
658   uint32_t errorFlags = 0;
659+  UNUSED_P(userData);
660
661   /* Expected model array structure is this:
662    * [0] (type 6, quant 0)
663@@ -3926,10 +3951,9 @@
664 #if defined(XML_CONTEXT_BYTES)
665 START_TEST(test_get_buffer_3_overflow) {
666   XML_Parser parser = XML_ParserCreate(NULL);
667-  assert(parser != NULL);
668-
669-  const char *const text = "\n";
670+  const char *text = "\n";
671   const int expectedKeepValue = (int)strlen(text);
672+  assert(parser != NULL);
673
674   // After this call, variable "keep" in XML_GetBuffer will
675   // have value expectedKeepValue
676@@ -4992,8 +5016,8 @@
677
678 static void XMLCALL
679 suspending_comment_handler(void *userData, const XML_Char *data) {
680-  UNUSED_P(data);
681   XML_Parser parser = (XML_Parser)userData;
682+  UNUSED_P(data);
683   XML_StopParser(parser, XML_TRUE);
684 }
685
686@@ -6210,13 +6234,16 @@
687     for (; j < sizeof(atNameStart) / sizeof(atNameStart[0]); j++) {
688       const bool expectedSuccess
689           = atNameStart[j] ? cases[i].goodNameStart : cases[i].goodName;
690+      XML_Parser parser;
691+      enum XML_Status status;
692+      bool success;
693       sprintf(doc, "<%s%s><!--", atNameStart[j] ? "" : "a", cases[i].tagName);
694-      XML_Parser parser = XML_ParserCreate(NULL);
695+      parser = XML_ParserCreate(NULL);
696
697-      const enum XML_Status status
698+      status
699           = XML_Parse(parser, doc, (int)strlen(doc), /*isFinal=*/XML_FALSE);
700
701-      bool success = true;
702+      success = true;
703       if ((status == XML_STATUS_OK) != expectedSuccess) {
704         success = false;
705       }
706@@ -6812,13 +6839,14 @@
707   CharData storage;
708   XML_Parser parser = XML_ParserCreate(NULL);
709   ParserPlusStorage parserPlusStorage = {parser, &storage};
710-
711+  enum XML_Status status;
712+
713   CharData_Init(&storage);
714   XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
715   XML_SetCommentHandler(parser, accumulate_and_suspend_comment_handler);
716   XML_SetUserData(parser, &parserPlusStorage);
717
718-  enum XML_Status status = XML_Parse(parser, text, (int)strlen(text), XML_TRUE);
719+  status = XML_Parse(parser, text, (int)strlen(text), XML_TRUE);
720   while (status == XML_STATUS_SUSPENDED) {
721     status = XML_ResumeParser(parser);
722   }
723@@ -10214,6 +10242,8 @@
724                                                  const XML_Char *base,
725                                                  const XML_Char *systemId,
726                                                  const XML_Char *publicId) {
727+  const XML_Char *encodingName = XCS("UTF-8"); // needs something non-NULL
728+  XML_Parser ext_parser;
729   UNUSED_P(base);
730   UNUSED_P(systemId);
731   UNUSED_P(publicId);
732@@ -10226,8 +10256,7 @@
733   // &(parser->m_mem));" in function parserInit.
734   allocation_count = 3;
735
736-  const XML_Char *const encodingName = XCS("UTF-8"); // needs something non-NULL
737-  const XML_Parser ext_parser
738+  ext_parser
739       = XML_ExternalEntityParserCreate(parser, context, encodingName);
740   if (ext_parser != NULL)
741     fail(
742@@ -11718,14 +11747,17 @@
743                                        const XML_Char *base,
744                                        const XML_Char *systemId,
745                                        const XML_Char *publicId) {
746-  UNUSED_P(context);
747-  UNUSED_P(base);
748-  UNUSED_P(publicId);
749-
750   const struct AccountingTestCase *const testCase
751       = (const struct AccountingTestCase *)XML_GetUserData(parser);
752
753   const char *externalText = NULL;
754+  XML_Parser entParser;
755+  XmlParseFunction xmlParseFunction;
756+  enum XML_Status status;
757+  UNUSED_P(context);
758+  UNUSED_P(base);
759+  UNUSED_P(publicId);
760+
761   if (xcstrcmp(systemId, XCS("first.ent")) == 0) {
762     externalText = testCase->firstExternalText;
763   } else if (xcstrcmp(systemId, XCS("second.ent")) == 0) {
764@@ -11735,13 +11767,13 @@
765   }
766   assert(externalText);
767
768-  XML_Parser entParser = XML_ExternalEntityParserCreate(parser, context, 0);
769+  entParser = XML_ExternalEntityParserCreate(parser, context, 0);
770   assert(entParser);
771
772-  const XmlParseFunction xmlParseFunction
773+  xmlParseFunction
774       = testCase->singleBytesWanted ? _XML_Parse_SINGLE_BYTES : XML_Parse;
775
776-  const enum XML_Status status = xmlParseFunction(
777+  status = xmlParseFunction(
778       entParser, externalText, (int)strlen(externalText), XML_TRUE);
779
780   XML_ParserFree(entParser);
781@@ -11951,6 +11983,10 @@
782             + cases[u].expectedCountBytesIndirectExtra;
783
784       XML_Parser parser = XML_ParserCreate(NULL);
785+      XmlParseFunction xmlParseFunction;
786+      enum XML_Status status;
787+      unsigned long long actualCountBytesDirect;
788+      unsigned long long actualCountBytesIndirect;
789       XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
790       if (cases[u].firstExternalText) {
791         XML_SetExternalEntityRefHandler(parser,
792@@ -11959,19 +11995,19 @@
793         cases[u].singleBytesWanted = singleBytesWanted;
794       }
795
796-      const XmlParseFunction xmlParseFunction
797+      xmlParseFunction
798           = singleBytesWanted ? _XML_Parse_SINGLE_BYTES : XML_Parse;
799
800-      enum XML_Status status
801+      status
802           = xmlParseFunction(parser, cases[u].primaryText,
803                              (int)strlen(cases[u].primaryText), XML_TRUE);
804       if (status != XML_STATUS_OK) {
805         _xml_failure(parser, __FILE__, __LINE__);
806       }
807
808-      const unsigned long long actualCountBytesDirect
809+      actualCountBytesDirect
810           = testingAccountingGetCountBytesDirect(parser);
811-      const unsigned long long actualCountBytesIndirect
812+      actualCountBytesIndirect
813           = testingAccountingGetCountBytesIndirect(parser);
814
815       XML_ParserFree(parser);
816