[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - connectivity/source include/sal
Michael Stahl
mstahl at redhat.com
Tue Jun 7 07:29:38 UTC 2016
connectivity/source/drivers/dbase/DIndex.cxx | 33 +++++++++++++++++++++++--
connectivity/source/drivers/dbase/DIndexes.cxx | 2 -
connectivity/source/drivers/dbase/DTable.cxx | 13 ++++++++-
connectivity/source/inc/dbase/DIndex.hxx | 2 +
include/sal/log-areas.dox | 3 +-
5 files changed, 47 insertions(+), 6 deletions(-)
New commits:
commit 59ac316ece6d38770dc7b1e0e1cad749101cb808
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Jun 3 22:53:20 2016 +0200
connectivity: DBase: fix some obvious endian issues
These calls to SvStream::Read/Write operate on structs that contain
32-bit integers.
(cherry picked from commit 4849f342b6969abb777d91a1fa77ec120f861c48)
loplugin:sallogareas
(cherry picked from commit 6bd1465395064f60c4ac45bbd79571149a702d0b)
connectivity: -Werror=unused-variable
(cherry picked from commit 296125b0bf28af9ec6f0ab1459b392e26ed3eb3f)
loplugin:sallogareas
(cherry picked from commit 106bcf136892944d9430ffa70d21de641bb44441)
Change-Id: I2d45128ad482013cd9ef1fca0dd259dfc09c904f
Reviewed-on: https://gerrit.libreoffice.org/25991
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx
index a2e8e3e9..423fd3a 100644
--- a/connectivity/source/drivers/dbase/DIndex.cxx
+++ b/connectivity/source/drivers/dbase/DIndex.cxx
@@ -349,11 +349,29 @@ ONDXPage* ODbaseIndex::CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent, bool b
return pPage;
}
+void connectivity::dbase::ReadHeader(
+ SvStream & rStream, ODbaseIndex::NDXHeader & rHeader)
+{
+#if !defined(NDEBUG)
+ sal_uInt64 const nOldPos(rStream.Tell());
+#endif
+ rStream.ReadUInt32(rHeader.db_rootpage);
+ rStream.ReadUInt32(rHeader.db_pagecount);
+ rStream.Read(&rHeader.db_frei, 4);
+ rStream.ReadUInt16(rHeader.db_keylen);
+ rStream.ReadUInt16(rHeader.db_maxkeys);
+ rStream.ReadUInt16(rHeader.db_keytype);
+ rStream.ReadUInt16(rHeader.db_keyrec);
+ rStream.Read(&rHeader.db_frei1, 3);
+ rStream.ReadUChar(rHeader.db_unique);
+ rStream.Read(&rHeader.db_name, 488);
+ assert(rStream.GetError() || rStream.Tell() == nOldPos + DINDEX_PAGE_SIZE);
+}
SvStream& connectivity::dbase::operator >> (SvStream &rStream, ODbaseIndex& rIndex)
{
rStream.Seek(0);
- rStream.Read(&rIndex.m_aHeader,DINDEX_PAGE_SIZE);
+ ReadHeader(rStream, rIndex.m_aHeader);
rIndex.m_nRootPage = rIndex.m_aHeader.db_rootpage;
rIndex.m_nPageCount = rIndex.m_aHeader.db_pagecount;
@@ -363,7 +381,18 @@ SvStream& connectivity::dbase::operator >> (SvStream &rStream, ODbaseIndex& rInd
SvStream& connectivity::dbase::WriteODbaseIndex(SvStream &rStream, ODbaseIndex& rIndex)
{
rStream.Seek(0);
- OSL_VERIFY( rStream.Write(&rIndex.m_aHeader,DINDEX_PAGE_SIZE) == DINDEX_PAGE_SIZE );
+ rStream.WriteUInt32(rIndex.m_aHeader.db_rootpage);
+ rStream.WriteUInt32(rIndex.m_aHeader.db_pagecount);
+ rStream.Write(&rIndex.m_aHeader.db_frei, 4);
+ rStream.WriteUInt16(rIndex.m_aHeader.db_keylen);
+ rStream.WriteUInt16(rIndex.m_aHeader.db_maxkeys);
+ rStream.WriteUInt16(rIndex.m_aHeader.db_keytype);
+ rStream.WriteUInt16(rIndex.m_aHeader.db_keyrec);
+ rStream.Write(&rIndex.m_aHeader.db_frei1, 3);
+ rStream.WriteUChar(rIndex.m_aHeader.db_unique);
+ rStream.Write(&rIndex.m_aHeader.db_name, 488);
+ assert(rStream.GetError() || rStream.Tell() == DINDEX_PAGE_SIZE);
+ SAL_WARN_IF(rStream.GetError(), "connectivity.dbase", "write error");
return rStream;
}
diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx
index 939fd8a..34e98ec 100644
--- a/connectivity/source/drivers/dbase/DIndexes.cxx
+++ b/connectivity/source/drivers/dbase/DIndexes.cxx
@@ -60,7 +60,7 @@ sdbcx::ObjectType ODbaseIndexes::createObject(const OUString& _rName)
ODbaseIndex::NDXHeader aHeader;
pFileStream->Seek(0);
- pFileStream->Read(&aHeader,DINDEX_PAGE_SIZE);
+ ReadHeader(*pFileStream, aHeader);
delete pFileStream;
ODbaseIndex* pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
index 391a5ed..b6ef203 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -323,8 +323,17 @@ void ODbaseTable::fillColumns()
for (; i < nFieldCount; i++)
{
DBFColumn aDBFColumn;
- sal_Size nRead = m_pFileStream->Read(&aDBFColumn, sizeof(aDBFColumn));
- if (nRead != sizeof(aDBFColumn))
+#if !defined(NDEBUG)
+ sal_uInt64 const nOldPos(m_pFileStream->Tell());
+#endif
+ m_pFileStream->Read(aDBFColumn.db_fnm, 11);
+ m_pFileStream->ReadUChar(aDBFColumn.db_typ);
+ m_pFileStream->ReadUInt32(aDBFColumn.db_adr);
+ m_pFileStream->ReadUChar(aDBFColumn.db_flng);
+ m_pFileStream->ReadUChar(aDBFColumn.db_dez);
+ m_pFileStream->Read(aDBFColumn.db_frei2, 14);
+ assert(m_pFileStream->GetError() || m_pFileStream->Tell() == nOldPos + sizeof(aDBFColumn));
+ if (m_pFileStream->GetError())
{
SAL_WARN("connectivity.drivers", "ODbaseTable::fillColumns: short read!");
break;
diff --git a/connectivity/source/inc/dbase/DIndex.hxx b/connectivity/source/inc/dbase/DIndex.hxx
index 115b14d..60a3969 100644
--- a/connectivity/source/inc/dbase/DIndex.hxx
+++ b/connectivity/source/inc/dbase/DIndex.hxx
@@ -139,6 +139,8 @@ namespace connectivity
SvStream& WriteODbaseIndex(SvStream &rStream, ODbaseIndex&);
SvStream& operator >> (SvStream &rStream, ODbaseIndex&);
+
+ void ReadHeader(SvStream & rStream, ODbaseIndex::NDXHeader & rHeader);
}
}
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index cbb93eb..06da4f8 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -72,7 +72,8 @@ certain functionality.
@li @c connectivity.commontools
@li @c connectivity.cpool
- at li @c connectivity.drivers
+ at li @c connectivity.drivers - a bit overly general, maybe it should be removed?
+ at li @c connectivity.dbase
@li @c connectivity.evoab2
@li @c connectivity.firebird
@li @c connectivity.flat
More information about the Libreoffice-commits
mailing list