aboutsummaryrefslogtreecommitdiff
blob: 19e5bb1de12d05a8fecdb3b507991e3177eb86c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From 510751e4f02f8ae7c887bc04b84448d8aee9831d Mon Sep 17 00:00:00 2001
From: Markus Rothe <markus@unixforces.net>
Date: Tue, 30 Sep 2008 16:38:07 +0200
Subject: [PATCH 24/48] fix issue on 64bit big endian architectures.

On 64bit big endian architectures, PowerPC64 in my case, off_t is 64bit. Now
rule.jump_position is only 32bit. the pad32_write function call in
set_jump_position only saves 32bit. On little endian architectures this are
the "correct" bits, but not on 64bit architectures which are big endian. The
solution is to type cast off_t to a 32bit value and save this one instead of
the original variable.
---
 hald/create_cache.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/hald/create_cache.c b/hald/create_cache.c
index d52f834..232fe98 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -305,15 +305,17 @@ static void remember_jump_position(struct fdi_context *fdi_ctx)
 static void set_jump_position(struct fdi_context *fdi_ctx)
 {
 	off_t	offset;
+	u_int32_t offset32;
 
 	if (fdi_ctx->depth <= 0)
 		DIE(("Rule depth underrun"));
 
 	fdi_ctx->depth--;
 	offset = RULES_ROUND(lseek(fdi_ctx->cache_fd, 0, SEEK_END));
+	offset32 = (u_int32_t)offset;
 	pad32_write(fdi_ctx->cache_fd,
 		fdi_ctx->match_at_depth[fdi_ctx->depth] + offsetof(struct rule, jump_position),
-		&offset, sizeof(fdi_ctx->rule.jump_position));
+		&offset32, sizeof(fdi_ctx->rule.jump_position));
 
 	if (haldc_verbose)
 		HAL_INFO(("modify rule=0x%08x, set jump to 0x%08x",
-- 
1.6.1.2