head 1.1; branch 1.1.1; access; symbols expat-2-8-2:1.1.1.2 netbsd-11-0-RC5:1.1.1.1.2.2 netbsd-11:1.1.1.1.0.2 expat-2-8-1:1.1.1.1 expat:1.1.1; locks; strict; comment @ * @; 1.1 date 2026.06.13.16.41.48; author jdc; state Exp; branches 1.1.1.1; next ; commitid OvLcw9veAeJ0QEJG; 1.1.1.1 date 2026.06.13.16.41.48; author jdc; state Exp; branches 1.1.1.1.2.1; next 1.1.1.2; commitid OvLcw9veAeJ0QEJG; 1.1.1.2 date 2026.06.26.08.32.42; author jdc; state Exp; branches; next ; commitid 7WndiZKtdregIhLG; 1.1.1.1.2.1 date 2026.06.13.16.41.48; author martin; state dead; branches; next 1.1.1.1.2.2; commitid CEh2BY99NRqLYZJG; 1.1.1.1.2.2 date 2026.06.16.08.23.22; author martin; state Exp; branches; next 1.1.1.1.2.3; commitid CEh2BY99NRqLYZJG; 1.1.1.1.2.3 date 2026.06.27.16.32.24; author martin; state Exp; branches; next ; commitid fu6p5tMN9x7FksLG; desc @@ 1.1 log @Initial revision @ text @/* __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| | __// \| |_) | (_| | |_ \___/_/\_\ .__/ \__,_|\__| |_| XML parser Copyright (c) 2017-2026 Sebastian Pipping Copyright (c) 2017 Chanho Park Copyright (c) 2022 Sean McBride Copyright (c) 2026 Matthew Fernandez Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "random_getrandom.h" #include "expat_config.h" // for HAVE_GETRANDOM, HAVE_SYSCALL_GETRANDOM #if defined(HAVE_GETRANDOM) # include /* getrandom */ #endif #if defined(HAVE_SYSCALL_GETRANDOM) # if ! defined(_GNU_SOURCE) # define _GNU_SOURCE 1 /* syscall prototype */ # endif # include /* syscall */ # include /* SYS_getrandom */ #endif // defined(HAVE_SYSCALL_GETRANDOM) #if ! defined(GRND_NONBLOCK) # define GRND_NONBLOCK 0x0001 #endif /* defined(GRND_NONBLOCK) */ #include #include #include // for INT_MAX /* Obtain entropy on Linux 3.17+ */ bool writeRandomBytes_getrandom_nonblock(void *target, size_t count) { int success = false; /* full count bytes written? */ size_t bytesWrittenTotal = 0; const unsigned int getrandomFlags = GRND_NONBLOCK; do { void *const currentTarget = (void *)((char *)target + bytesWrittenTotal); const size_t bytesToWrite = count - bytesWrittenTotal; assert(bytesToWrite <= INT_MAX); errno = 0; const int bytesWrittenMore = #if defined(HAVE_GETRANDOM) (int)getrandom(currentTarget, bytesToWrite, getrandomFlags); #else (int)syscall(SYS_getrandom, currentTarget, bytesToWrite, getrandomFlags); #endif if (bytesWrittenMore > 0) { bytesWrittenTotal += bytesWrittenMore; if (bytesWrittenTotal >= count) success = true; } } while (! success && (errno == EINTR)); return success; } @ 1.1.1.1 log @Import expat 2.8.1 as expat-2-8-1 @ text @@ 1.1.1.2 log @Import expat 2.8.2 as expat-2-8-2 @ text @d35 2 a38 2 #include "random_getrandom.h" a54 1 #include "memory_sanitizer.h" d67 1 a67 1 void *const currentTarget = (char *)target + bytesWrittenTotal; a76 1 // MSan understands `getrandom`, so does not need extra guidance a79 3 // MSan does not understand `syscall`, so explain its effects if (bytesWrittenMore > 0) MSAN_UNPOISON(currentTarget, bytesWrittenMore); @ 1.1.1.1.2.1 log @file random_getrandom.c was added on branch netbsd-11 on 2026-06-16 08:23:22 +0000 @ text @d1 90 @ 1.1.1.1.2.2 log @Pull up the following revisions, requested by jdc in ticket #311: external/mit/expat/dist/lib/libexpat.map.in up to 1.1.1.1 external/mit/expat/dist/lib/random_arc4random.c up to 1.1.1.1 external/mit/expat/dist/lib/random_arc4random.h up to 1.1.1.1 external/mit/expat/dist/lib/random_arc4random_buf.c up to 1.1.1.1 external/mit/expat/dist/lib/random_arc4random_buf.h up to 1.1.1.1 external/mit/expat/dist/lib/random_dev_urandom.c up to 1.1.1.1 external/mit/expat/dist/lib/random_dev_urandom.h up to 1.1.1.1 external/mit/expat/dist/lib/random_getentropy.c up to 1.1.1.1 external/mit/expat/dist/lib/random_getentropy.h up to 1.1.1.1 external/mit/expat/dist/lib/random_getrandom.c up to 1.1.1.1 external/mit/expat/dist/lib/random_getrandom.h up to 1.1.1.1 external/mit/expat/dist/lib/random_rand_s.c up to 1.1.1.1 external/mit/expat/dist/lib/random_rand_s.h up to 1.1.1.1 external/mit/expat/dist/coverage.sh up to 1.1.1.1 external/mit/expat/dist/cmake/autotools/expat__linux.cmake.in up to 1.1.1.1 external/mit/expat/dist/cmake/autotools/expat__macos.cmake.in up to 1.1.1.1 external/mit/expat/dist/cmake/autotools/expat__windows.cmake.in up to 1.1.1.1 external/mit/expat/dist/qa.sh up to 1.1.1.1 external/mit/expat/dist/gennmtab/gennmtab.c up to 1.1.1.1 external/mit/expat/dist/.clang-format up to 1.1.1.1 external/mit/expat/dist/apply-clang-format.sh up to 1.1.1.1 external/mit/expat/dist/apply-clang-tidy.sh up to 1.1.1.1 external/mit/expat/dist/clean_coverage.sh up to 1.1.1.1 external/mit/expat/dist/configure-ac-style.md up to 1.1.1.1 external/mit/expat/dist/distribute.sh up to 1.1.1.1 external/mit/expat/dist/memory-sanitizer-blacklist.txt up to 1.1.1.1 external/mit/expat/dist/Makefile.in delete external/mit/expat/dist/aclocal.m4 delete external/mit/expat/dist/configure delete external/mit/expat/dist/expat_config.h.in delete external/mit/expat/dist/cmake/autotools/expat.cmake delete external/mit/expat/dist/conftools/compile delete external/mit/expat/dist/conftools/ar-lib delete external/mit/expat/dist/conftools/config.guess delete external/mit/expat/dist/conftools/config.sub delete external/mit/expat/dist/conftools/depcomp delete external/mit/expat/dist/conftools/expat.m4 delete external/mit/expat/dist/conftools/missing delete external/mit/expat/dist/conftools/install-sh delete external/mit/expat/dist/conftools/ltmain.sh delete external/mit/expat/dist/conftools/test-driver delete external/mit/expat/dist/doc/Makefile.in delete external/mit/expat/dist/doc/xmlwf.1 delete external/mit/expat/dist/examples/Makefile.in delete external/mit/expat/dist/lib/Makefile.in delete external/mit/expat/dist/m4/libtool.m4 delete external/mit/expat/dist/m4/ltoptions.m4 delete external/mit/expat/dist/m4/ltsugar.m4 delete external/mit/expat/dist/m4/ltversion.m4 delete external/mit/expat/dist/m4/lt~obsolete.m4 delete external/mit/expat/dist/tests/benchmark/Makefile.in delete external/mit/expat/dist/tests/Makefile.in delete external/mit/expat/dist/tests/acc_tests_cxx.cpp delete external/mit/expat/dist/tests/alloc_tests_cxx.cpp delete external/mit/expat/dist/tests/basic_tests_cxx.cpp delete external/mit/expat/dist/tests/chardata_cxx.cpp delete external/mit/expat/dist/tests/common_cxx.cpp delete external/mit/expat/dist/tests/dummy_cxx.cpp delete external/mit/expat/dist/tests/handlers_cxx.cpp delete external/mit/expat/dist/tests/memcheck_cxx.cpp delete external/mit/expat/dist/tests/minicheck_cxx.cpp delete external/mit/expat/dist/tests/misc_tests_cxx.cpp delete external/mit/expat/dist/tests/ns_tests_cxx.cpp delete external/mit/expat/dist/tests/nsalloc_tests_cxx.cpp delete external/mit/expat/dist/tests/runtests_cxx.cpp delete external/mit/expat/dist/tests/structdata_cxx.cpp delete external/mit/expat/dist/xmlwf/Makefile.in delete external/mit/expat/dist/CMake.README up to 1.1.1.9 external/mit/expat/dist/CMakeLists.txt up to 1.1.1.9 external/mit/expat/dist/Changes up to 1.1.1.10 external/mit/expat/dist/ConfigureChecks.cmake up to 1.1.1.5 external/mit/expat/dist/Makefile.am up to 1.1.1.5 external/mit/expat/dist/README.md up to 1.1.1.5 external/mit/expat/dist/configure.ac up to 1.1.1.8 external/mit/expat/dist/expat_config.h.cmake up to 1.1.1.4 external/mit/expat/dist/fix-xmltest-log.sh up to 1.1.1.4 external/mit/expat/dist/doc/reference.html up to 1.1.1.9 external/mit/expat/dist/doc/xmlwf.xml up to 1.1.1.6 external/mit/expat/dist/examples/element_declarations.c up to 1.1.1.2 external/mit/expat/dist/fuzz/xml_lpm_fuzzer.cpp up to 1.1.1.2 external/mit/expat/dist/fuzz/xml_parse_fuzzer.c up to 1.1.1.3 external/mit/expat/dist/fuzz/xml_parsebuffer_fuzzer.c up to 1.1.1.3 external/mit/expat/dist/lib/Makefile.am up to 1.1.1.4 external/mit/expat/dist/lib/expat.h up to 1.1.1.10 external/mit/expat/dist/lib/expat_external.h up to 1.1.1.6 external/mit/expat/dist/lib/internal.h up to 1.1.1.7 external/mit/expat/dist/lib/libexpat.def.cmake up to 1.1.1.2 external/mit/expat/dist/lib/xmlparse.c up to 1.12 external/mit/expat/dist/lib/xmlrole.c up to 1.1.1.8 external/mit/expat/dist/lib/xmlrole.h up to 1.1.1.5 external/mit/expat/dist/lib/xmltok.c up to 1.8 external/mit/expat/dist/lib/xmltok.h up to 1.6 external/mit/expat/dist/lib/xmltok_ns.c up to 1.1.1.4 external/mit/expat/dist/tests/Makefile.am up to 1.1.1.4 external/mit/expat/dist/tests/alloc_tests.c up to 1.1.1.2 external/mit/expat/dist/tests/basic_tests.c up to 1.1.1.2 external/mit/expat/dist/tests/common.c up to 1.1.1.3 external/mit/expat/dist/tests/handlers.c up to 1.1.1.2 external/mit/expat/dist/tests/handlers.h up to 1.1.1.2 external/mit/expat/dist/tests/memcheck.c up to 1.1.1.5 external/mit/expat/dist/tests/minicheck.c up to 1.1.1.7 external/mit/expat/dist/tests/minicheck.h up to 1.1.1.8 external/mit/expat/dist/tests/misc_tests.c up to 1.1.1.3 external/mit/expat/dist/tests/nsalloc_tests.c up to 1.1.1.2 external/mit/expat/dist/tests/structdata.c up to 1.1.1.4 external/mit/expat/dist/tests/xmltest.sh up to 1.7 external/mit/expat/dist/win32/README.txt up to 1.1.1.7 external/mit/expat/dist/win32/build_expat_iss.bat up to 1.1.1.4 external/mit/expat/dist/win32/expat.iss up to 1.1.1.10 external/mit/expat/dist/xmlwf/unixfilemap.c up to 1.1.1.6 external/mit/expat/dist/xmlwf/xmlfile.c up to 1.1.1.7 external/mit/expat/dist/xmlwf/xmlwf.c up to 1.1.1.9 external/mit/expat/dist/xmlwf/xmlwf_helpgen.py up to 1.1.1.4 Import expat 2.8.1 as expat-2-8-1 Merge expat 2.8.1 @ text @a0 90 /* __ __ _ ___\ \/ /_ __ __ _| |_ / _ \\ /| '_ \ / _` | __| | __// \| |_) | (_| | |_ \___/_/\_\ .__/ \__,_|\__| |_| XML parser Copyright (c) 2017-2026 Sebastian Pipping Copyright (c) 2017 Chanho Park Copyright (c) 2022 Sean McBride Copyright (c) 2026 Matthew Fernandez Licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "random_getrandom.h" #include "expat_config.h" // for HAVE_GETRANDOM, HAVE_SYSCALL_GETRANDOM #if defined(HAVE_GETRANDOM) # include /* getrandom */ #endif #if defined(HAVE_SYSCALL_GETRANDOM) # if ! defined(_GNU_SOURCE) # define _GNU_SOURCE 1 /* syscall prototype */ # endif # include /* syscall */ # include /* SYS_getrandom */ #endif // defined(HAVE_SYSCALL_GETRANDOM) #if ! defined(GRND_NONBLOCK) # define GRND_NONBLOCK 0x0001 #endif /* defined(GRND_NONBLOCK) */ #include #include #include // for INT_MAX /* Obtain entropy on Linux 3.17+ */ bool writeRandomBytes_getrandom_nonblock(void *target, size_t count) { int success = false; /* full count bytes written? */ size_t bytesWrittenTotal = 0; const unsigned int getrandomFlags = GRND_NONBLOCK; do { void *const currentTarget = (void *)((char *)target + bytesWrittenTotal); const size_t bytesToWrite = count - bytesWrittenTotal; assert(bytesToWrite <= INT_MAX); errno = 0; const int bytesWrittenMore = #if defined(HAVE_GETRANDOM) (int)getrandom(currentTarget, bytesToWrite, getrandomFlags); #else (int)syscall(SYS_getrandom, currentTarget, bytesToWrite, getrandomFlags); #endif if (bytesWrittenMore > 0) { bytesWrittenTotal += bytesWrittenMore; if (bytesWrittenTotal >= count) success = true; } } while (! success && (errno == EINTR)); return success; } @ 1.1.1.1.2.3 log @Pull up the following, requested by jdc in ticket #338: external/mit/expat/dist/lib/xcsinc.c up to 1.1.1.1 external/mit/expat/dist/lib/fallthrough.h up to 1.1.1.1 external/mit/expat/dist/lib/memory_sanitizer.h up to 1.1.1.1 external/mit/expat/dist/memory-sanitizer-blacklist.txt delete external/mit/expat/dist/CMake.README up to 1.1.1.10 external/mit/expat/dist/CMakeLists.txt up to 1.1.1.10 external/mit/expat/dist/Changes up to 1.1.1.11 external/mit/expat/dist/ConfigureChecks.cmake up to 1.1.1.6 external/mit/expat/dist/README.md up to 1.1.1.6 external/mit/expat/dist/configure.ac up to 1.1.1.9 external/mit/expat/dist/qa.sh up to 1.1.1.2 external/mit/expat/dist/doc/reference.html up to 1.1.1.10 external/mit/expat/dist/doc/xmlwf.xml up to 1.1.1.7 external/mit/expat/dist/lib/Makefile.am up to 1.1.1.5 external/mit/expat/dist/lib/expat.h up to 1.1.1.11 external/mit/expat/dist/lib/libexpat.def.cmake up to 1.1.1.3 external/mit/expat/dist/lib/random_arc4random_buf.c up to 1.1.1.2 external/mit/expat/dist/lib/random_dev_urandom.c up to 1.1.1.2 external/mit/expat/dist/lib/random_getentropy.c up to 1.1.1.2 external/mit/expat/dist/lib/random_getrandom.c up to 1.1.1.2 external/mit/expat/dist/lib/siphash.h up to 1.1.1.5 external/mit/expat/dist/lib/xmlparse.c up to 1.13 external/mit/expat/dist/lib/xmltok.c up to 1.9 external/mit/expat/dist/lib/xmltok_impl.c up to 1.9 external/mit/expat/dist/tests/acc_tests.c up to 1.1.1.2 external/mit/expat/dist/tests/alloc_tests.c up to 1.1.1.3 external/mit/expat/dist/tests/basic_tests.c up to 1.1.1.3 external/mit/expat/dist/tests/chardata.c up to 1.1.1.7 external/mit/expat/dist/tests/common.c up to 1.1.1.4 external/mit/expat/dist/tests/handlers.c up to 1.1.1.3 external/mit/expat/dist/tests/handlers.h up to 1.1.1.3 external/mit/expat/dist/tests/misc_tests.c up to 1.1.1.4 external/mit/expat/dist/win32/expat.iss up to 1.1.1.11 external/mit/expat/dist/xmlwf/filemap.h up to 1.1.1.5 external/mit/expat/dist/xmlwf/win32filemap.c up to 1.1.1.6 external/mit/expat/dist/xmlwf/xmlfile.c up to 1.1.1.8 external/mit/expat/dist/xmlwf/xmlwf.c up to 1.1.1.10 external/mit/expat/dist/xmlwf/xmlwf_helpgen.py up to 1.1.1.5 Update expat to 2.8.2. @ text @d35 2 a38 2 #include "random_getrandom.h" a54 1 #include "memory_sanitizer.h" d67 1 a67 1 void *const currentTarget = (char *)target + bytesWrittenTotal; a76 1 // MSan understands `getrandom`, so does not need extra guidance a79 3 // MSan does not understand `syscall`, so explain its effects if (bytesWrittenMore > 0) MSAN_UNPOISON(currentTarget, bytesWrittenMore); @