aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-10-10 16:41:28 +0000
committerdrh <drh@noemail.net>2015-10-10 16:41:28 +0000
commit48310f8c5131bd5d07228c7bf8af71553e2854c4 (patch)
treeaf0968bb25c5c099bdb67266a1f3539a86816658 /src
parent72724da95a15ff501e113db849021905daa5b354 (diff)
downloadsqlite-48310f8c5131bd5d07228c7bf8af71553e2854c4.tar.gz
sqlite-48310f8c5131bd5d07228c7bf8af71553e2854c4.zip
Work around a "security feature" bug in memcpy() on OpenBSD.
FossilOrigin-Name: fab6f09044d033dd09ed8a22e06bc6a7851bbabf
Diffstat (limited to 'src')
-rw-r--r--src/btree.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/btree.c b/src/btree.c
index 1eae0ac5d..2c1a9983e 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -6499,7 +6499,13 @@ static int pageInsertArray(
if( pData<pBegin ) return 1;
pSlot = pData;
}
- memcpy(pSlot, pCArray->apCell[i], sz);
+ /* pSlot and pCArray->apCell[i] will never overlap on a well-formed
+ ** database. But they might for a corrupt database. Hence use memmove()
+ ** since memcpy() sends SIGABORT with overlapping buffers on OpenBSD */
+ assert( (pSlot+sz)<=pCArray->apCell[i]
+ || pSlot>=(pCArray->apCell[i]+sz)
+ || CORRUPT_DB );
+ memmove(pSlot, pCArray->apCell[i], sz);
put2byte(pCellptr, (pSlot - aData));
pCellptr += 2;
}