Bug#932090: firebird3.0: Please include patch to ensure correct sizes of on-disk structures
Source: firebird3.0
Version: 3.0.5.33100.ds4-3
Severity: normal
Tags: patch
User: debian-68k@lists.debian.org
Usertags: m68k
Hi!
firebird3.0 currently fails to build from source on m68k because the native
alignment of 16 bits on this architecture causes the on-disk structures to
have unexpected sizes.
With the attached patch, padding is added to the affected on-disk structures
such that the correct sizes are always guaranteed. Since this particular
padding happens automatically and implicitly for architectures with 32 or
64 bits native alignment, the actual sizes and offsets of the on-disk
structures do not change and therefore no compatibility break is going
to occur.
Using explicit padding has the advantage that the actual sizes and offsets
are completely visible and transparent to anyone reading the code.
I will forward this patch upstream.
Thanks,
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - glaubitz@debian.org
`. `' Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Description: Add padding for on-disk structures
In order to guarantee that the on-disk structures have always the expected
sizes, we should use padding fields within these structs rather than relying
on the native alignment of the target architecture which can result in
unexpected sizes for architectures with unusual native alignment.
.
Author: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Last-Update: 2019-07-14
Index: firebird3.0-3.0.5.33100.ds4/src/jrd/ods.h
===================================================================
--- firebird3.0-3.0.5.33100.ds4.orig/src/jrd/ods.h
+++ firebird3.0-3.0.5.33100.ds4/src/jrd/ods.h
@@ -423,6 +423,7 @@ struct header_page
SLONG hdr_att_high; // High word of the next attachment counter
USHORT hdr_tra_high[4]; // High words of the transaction counters
UCHAR hdr_data[1]; // Misc data
+ USHORT hdr_padding; // Padding
};
#define HDR_SIZE static_cast<FB_SIZE_T>(offsetof(Ods::header_page, hdr_data[0]))
@@ -479,6 +480,7 @@ struct page_inv_page
ULONG pip_extent; // Lowest free extent
ULONG pip_used; // Number of pages allocated from this PIP page
UCHAR pip_bits[1];
+ USHORT pip_padding; // Padding
};
@@ -530,6 +532,7 @@ struct pointer_page
USHORT ppg_count; // Number of slots active
USHORT ppg_relation; // Relation id
USHORT ppg_min_space; // Lowest slot with space available
+ USHORT ppg_padding; // Padding
ULONG ppg_page[1]; // Data page vector
};
@@ -564,6 +567,7 @@ struct tx_inv_page
pag tip_header;
ULONG tip_next; // Next transaction inventory page
UCHAR tip_transactions[1];
+ USHORT tip_padding; // Padding
};
@@ -588,6 +592,7 @@ struct rhd
USHORT rhd_flags; // flags, etc
UCHAR rhd_format; // format version
UCHAR rhd_data[1]; // record data
+ USHORT rhd_padding; // padding
};
#define RHD_SIZE static_cast<FB_SIZE_T>(offsetof(Ods::rhd, rhd_data[0]))
@@ -603,6 +608,7 @@ struct rhde
UCHAR rhde_format; // format version // until here, same as rhd
USHORT rhde_tra_high; // higher bits of transaction id
UCHAR rhde_data[1]; // record data
+ USHORT rhde_padding; // padding
};
#define RHDE_SIZE static_cast<FB_SIZE_T>(offsetof(Ods::rhde, rhde_data[0]))
@@ -634,6 +640,7 @@ struct blh
USHORT blh_max_segment; // Longest segment
USHORT blh_flags; // flags, etc
UCHAR blh_level; // Number of address levels, see blb_level in blb.h
+ USHORT blh_padding; // Padding
ULONG blh_count; // Total number of segments
ULONG blh_length; // Total length of data
USHORT blh_sub_type; // Blob sub-type
Index: firebird3.0-3.0.5.33100.ds4/src/misc/ods.txt
===================================================================
--- firebird3.0-3.0.5.33100.ds4.orig/src/misc/ods.txt
+++ firebird3.0-3.0.5.33100.ds4/src/misc/ods.txt
@@ -87,6 +87,7 @@ hdr_crypt_plugin 88
hdr_att_high 120
hdr_tra_high 124
hdr_data 132
+hdr_padding 134
*** struct page_inv_page 32
pip_header 0
@@ -94,6 +95,7 @@ pip_min 16
pip_extent 20
pip_used 24
pip_bits 28
+pip_padding 30
*** struct scns_page 24
scn_header 0
@@ -107,12 +109,14 @@ ppg_next 20
ppg_count 24
ppg_relation 26
ppg_min_space 28
+ppg_padding 30
ppg_page 32
*** struct tx_inv_page 24
tip_header 0
tip_next 16
tip_transactions 20
+tip_padding 22
*** struct generator_page 32
gpg_header 0
@@ -127,6 +131,7 @@ rhd_b_line 8
rhd_flags 10
rhd_format 12
rhd_data 13
+rhd_padding 14
*** struct rhde 20
rhde_transaction 0
@@ -136,6 +141,7 @@ rhde_flags 10
rhde_format 12
rhde_tra_high 14
rhde_data 16
+rhde_padding 18
*** struct rhdf 24
rhdf_transaction 0
@@ -154,6 +160,7 @@ blh_max_sequence 4
blh_max_segment 8
blh_flags 10
blh_level 12
+blh_padding 14
blh_count 16
blh_length 20
blh_sub_type 24
Reply to: