Skip to content

fix: crashes found by running every menu command - #2

Merged
qamarq merged 3 commits into
mainfrom
fix/library-file-paths
Oct 8, 2026
Merged

qamarq merged 3 commits into
mainfrom
fix/library-file-paths

Conversation

@qamarq

@qamarq qamarq commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Every menu command of the text-document and main menus (191 commands) was run in a fresh process with the new MFCWX_AUTOMATION script runner, started from / like Finder does. Before this PR 18 of them crashed; now all 191 open and close without crashing or hanging.

  • Caesar and every function that writes its result through libanalyse: libanalyse (ofstream) and cracklib (fopen) received CrypTool's Windows-style paths without conversion, so the result file was created under a literal name like \var\folders\...\cry6.txt (or not at all from Finder) and the next read crashed on a NULL FILE*. Both libraries are now compiled with mfcwx's fopen/fstream; their unit tests link plain stubs.
  • Brute-force analysis of IDEA, RC2, RC4, DES/3DES, AES candidates, DESX/DESL/DESXL (15 commands): the dialog runs in an AfxBeginThread worker; its control wrappers were destroyed there, but ~CWnd only detached from the wx window on the main thread, so the deferred wx deletion sent WM_DESTROY to freed objects.
  • Hybrid encryption demo: CWnd::SetFocus on a NULL wrapper (focus saved while the app was not active) now behaves like a NULL HWND.
  • Key generation from password (PKCS #5): two rand() values are formatted into char[20], sized for MSVC's RAND_MAX of 32767. The app now gets the Microsoft C runtime's rand/srand (same LCG, RAND_MAX 0x7fff), which also reproduces the Windows random sequences.

Not crashes, but still open (separate follow-ups): about 90 commands open no visible window in the automated run. Most are toggles, editing commands or native file dialogs; the rest include the Java (ANIMAL) and Flash animations and the external Windows tools.

qamarq added 3 commits October 8, 2026 14:53
libanalyse writes cipher results with ofstream and cracklib opens its
dictionary with fopen, both on paths CrypTool passes in Windows form. They
were built without mfcwx, so files landed under names like
"\var\folders\...\cry6.txt" in the working directory and the next read
crashed on a NULL FILE* (Caesar encryption, among others). Both libraries
are now compiled with mfcwx's fopen/fstream; their unit tests link stubs.

Also adds MFCWX_AUTOMATION, a small script runner (menu commands, dialog
buttons, control text, waits, snapshots) for reproducing UI flows.
The brute-force analysis dialogs run in AfxBeginThread workers. Their
control members were destroyed there, but ~CWnd only detached from the wx
window on the main thread, so the deferred wx deletion sent WM_DESTROY to
freed objects. The detach now always runs on the main thread. CWnd::SetFocus
also tolerates a NULL wrapper like a NULL HWND (hybrid encryption demo).
CrypTool sizes buffers for RAND_MAX 32767 (the PKCS #5 dialog writes two
rand() values into char[20] and overflowed with glibc/macOS RAND_MAX).
rand/srand now use the MSVC LCG and RAND_MAX 0x7fff, which also reproduces
the Windows random sequences; MIRACL's rand overloads are forwarded.
@qamarq qamarq changed the title fix(app): convert Windows paths in libanalyse and cracklib file access fix: crashes found by running every menu command Oct 8, 2026
@qamarq
qamarq merged commit d4450c2 into main Oct 8, 2026
5 checks passed
@qamarq
qamarq deleted the fix/library-file-paths branch October 8, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant