Skip to content

Use fixed-width reads for Btrieve file fields#1

Open
GregoryMorse wants to merge 6 commits into
erniehh:masterfrom
GregoryMorse:fix-fixed-width-btrieve-fields
Open

Use fixed-width reads for Btrieve file fields#1
GregoryMorse wants to merge 6 commits into
erniehh:masterfrom
GregoryMorse:fix-fixed-width-btrieve-fields

Conversation

@GregoryMorse

Copy link
Copy Markdown

This fixes LP64 portability issues when reading Btrieve on-disk fields.

The current code uses long / unsigned long and pointer casts for several serialized 32-bit fields. That works on Win32/Win64 because long is 32-bit there, but on Linux/macOS long is 64-bit, so packed structures and direct casts can read the wrong bytes.

Changes:

  • Use <stdint.h> fixed-width types for serialized page IDs and constants.
  • Add little-endian 16/32-bit read helpers for disk fields.
  • Replace host-sized pointer casts for FCR record counts, page IDs, page headers, PAT page pointers, and record headers.
  • Preserve the existing public API and behavior.

Validation:

  • Built BtrieveFileSaver.vcxproj with VS2022, Release|Win32.

@GregoryMorse

Copy link
Copy Markdown
Author

Just to note - this has been tested independently now on Windows, Linux, MacOS by just statically compiling against the BtrieveFileSaverLib.c and its header files.

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