OpenBSD: fix CLI build and PCSC exit handling

OpenBSD builds were relying on ggod to generate embedded resource
headers. That tool is not available on a stock OpenBSD 7.9 install,
and using base od directly is not a safe substitute because it emits
zero-padded decimal values such as 060 and 098. Those tokens are then
included in C++ source and parsed as octal constants, which either
changes values or fails compilation.

Use hexdump with an explicit unsigned-byte format for OpenBSD. It is
part of the base system and emits unpadded decimal byte values suitable
for the existing resource-header pipeline.

The text-mode binary also crashed on normal process exit on OpenBSD,
including after --version, --test, create, mount, list, and dismount.
GDB showed the crash in libpcsclite_real during SCardReleaseContext(),
called from the static SCardManager destructor. This happened even for
commands that did not use EMV or security-token support because the
static manager constructor eagerly initialized PC/SC at startup.

Avoid eager PC/SC initialization and exit-time finalization on OpenBSD.
The existing call sites still initialize PC/SC lazily when EMV/token
operations need it, while ordinary CLI commands no longer touch
pcsc-lite and no longer crash during static destruction.

Validated on OpenBSD 7.9 amd64 with:
- gmake NOGUI=1 -j2
- veracrypt --text --version
- veracrypt --text --test
- device-hosted create/mount/list/dismount smoke test through doas/vnd

Refs #1589.
Refs #1593.
This commit is contained in:
Mounir IDRASSI
2026-05-26 17:56:01 +09:00
parent 6774de941d
commit d0bc546614
2 changed files with 6 additions and 2 deletions

View File

@@ -96,7 +96,7 @@ endif
# Embedded files
ifeq "$(PLATFORM)" "OpenBSD"
OD_BIN := ggod -v -t u1 -A n
OD_BIN := hexdump -v -e '1/1 "%u "'
else
OD_BIN := od -v -t u1 -A n
endif

View File

@@ -7,12 +7,16 @@ namespace VeraCrypt
SCardManager::SCardManager()
{
#ifndef TC_OPENBSD
loader->Initialize();
#endif
}
SCardManager::~SCardManager()
{
#ifndef TC_OPENBSD
loader->Finalize();
#endif
}
vector<wstring> SCardManager::GetReaders()
@@ -106,4 +110,4 @@ namespace VeraCrypt
throw InvalidEMVPath();
}
}
}