From 023c5341fdd006c81f38a423c546141fe736ead0 Mon Sep 17 00:00:00 2001 From: martinh Date: Mon, 26 Jul 2010 09:27:14 +0000 Subject: [PATCH] Fix a sigbus due to unaligned memory access, found when compacting on sparc64. reads ok to gilles@ --- usr.sbin/ldapd/btree.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/usr.sbin/ldapd/btree.c b/usr.sbin/ldapd/btree.c index 6b4f75f563b..af2020bb256 100644 --- a/usr.sbin/ldapd/btree.c +++ b/usr.sbin/ldapd/btree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btree.c,v 1.28 2010/07/18 15:15:40 martinh Exp $ */ +/* $OpenBSD: btree.c,v 1.29 2010/07/26 09:27:14 martinh Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk @@ -2992,7 +2992,7 @@ btree_compact_tree(struct btree *bt, pgno_t pgno, struct btree *btc) { ssize_t rc; indx_t i; - pgno_t *pnext; + pgno_t *pnext, next; struct node *node; struct page *p; struct mpage *mp; @@ -3021,12 +3021,13 @@ btree_compact_tree(struct btree *bt, pgno_t pgno, struct btree *btc) for (i = 0; i < NUMKEYSP(p); i++) { node = NODEPTRP(p, i); if (F_ISSET(node->flags, F_BIGDATA)) { - pnext = NODEDATA(node); - *pnext = btree_compact_tree(bt, *pnext, btc); - if (*pnext == P_INVALID) { + bcopy(NODEDATA(node), &next, sizeof(next)); + next = btree_compact_tree(bt, next, btc); + if (next == P_INVALID) { free(p); return P_INVALID; } + bcopy(&next, NODEDATA(node), sizeof(next)); } } } else if (F_ISSET(p->flags, P_OVERFLOW)) { -- 2.20.1