aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-02-26 11:21:04 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-02-26 11:21:04 +0000
commit9aa5c652e9335650428fddc0b84037853a06256c (patch)
treefca2a743021743649528f130dfd4a29193ad1238
parent8e5de2aab7421677fd92a5f24da3d2a99dacf9f1 (diff)
downloadbusybox-9aa5c652e9335650428fddc0b84037853a06256c.tar.gz
unzip: fix thinko with le/be conv and size (closes bug 129)
awk: make "struct global" hack more robust wrt alignment (closes bug 131)
-rw-r--r--archival/unzip.c2
-rw-r--r--editors/awk.c15
2 files changed, 10 insertions, 7 deletions
diff --git a/archival/unzip.c b/archival/unzip.c
index e468ff451..7b47a8ab8 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -140,7 +140,7 @@ struct BUG_cde_header_must_be_16_bytes {
};
#define FIX_ENDIANNESS_CDE(cde_header) do { \
- (cde_header).formatted.cds_offset = SWAP_LE16((cde_header).formatted.cds_offset); \
+ (cde_header).formatted.cds_offset = SWAP_LE32((cde_header).formatted.cds_offset); \
} while (0)
enum { zip_fd = 3 };
diff --git a/editors/awk.c b/editors/awk.c
index bac580497..3f8368c8f 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -389,8 +389,12 @@ static const uint16_t PRIMES[] ALIGN2 = { 251, 1021, 4093, 16381, 65521 };
/* Globals. Split in two parts so that first one is addressed
- * with (mostly short) negative offsets */
+ * with (mostly short) negative offsets.
+ * NB: it's unsafe to put members of type "double"
+ * into globals2 (gcc may fail to align them).
+ */
struct globals {
+ double t_double;
chain beginseq, mainseq, endseq;
chain *seq;
node *break_ptr, *continue_ptr;
@@ -439,16 +443,16 @@ struct globals2 {
tsplitter exec_builtin__tspl;
/* biggest and least used members go last */
- double t_double;
tsplitter fsplitter, rsplitter;
};
#define G1 (ptr_to_globals[-1])
#define G (*(struct globals2 *)ptr_to_globals)
/* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */
-/* char G1size[sizeof(G1)]; - 0x6c */
-/* char Gsize[sizeof(G)]; - 0x1cc */
+/*char G1size[sizeof(G1)]; - 0x74 */
+/*char Gsize[sizeof(G)]; - 0x1c4 */
/* Trying to keep most of members accessible with short offsets: */
-/* char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; - 0x90 */
+/*char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; - 0x90 */
+#define t_double (G1.t_double )
#define beginseq (G1.beginseq )
#define mainseq (G1.mainseq )
#define endseq (G1.endseq )
@@ -476,7 +480,6 @@ struct globals2 {
#define t_info (G.t_info )
#define t_tclass (G.t_tclass )
#define t_string (G.t_string )
-#define t_double (G.t_double )
#define t_lineno (G.t_lineno )
#define t_rollback (G.t_rollback )
#define intvar (G.intvar )