#At file:///home/msvensson/mysql/bug/39540/ based on revid:jonas@stripped7bvrt9u63k
2923 Magnus Blåudd 2009-04-02
Bug#39540 ndb_restore crash while restoring log from different
endian
- Don't call 'Twiddle' when attribute is NULL
- Add asserts to early detect that 'Twiddle' is not called for NULL
modified:
storage/ndb/tools/restore/Restore.cpp
storage/ndb/tools/restore/Restore.hpp
=== modified file 'storage/ndb/tools/restore/Restore.cpp'
--- a/storage/ndb/tools/restore/Restore.cpp 2009-02-20 08:51:22 +0000
+++ b/storage/ndb/tools/restore/Restore.cpp 2009-04-02 18:18:08 +0000
@@ -34,9 +34,19 @@ Uint32 Twiddle32(Uint32 in); // Byte shi
Uint64 Twiddle64(Uint64 in); // Byte shift 64-bit data
bool
-BackupFile::Twiddle(const AttributeDesc* attr_desc, AttributeData* attr_data, Uint32 arraySize){
+BackupFile::Twiddle(const AttributeDesc * const attr_desc,
+ AttributeData* attr_data, Uint32 arraySize) const
+{
Uint32 i;
+ // Check parameters are not NULL
+ assert(attr_desc);
+ assert(attr_data);
+
+ // Make sure there is data to fiddle with
+ assert(!attr_data->null);
+ assert(attr_data->void_value);
+
if(m_hostByteOrder)
return true;
@@ -1618,10 +1628,10 @@ RestoreLogIterator::getNextLogEntry(int
AttributeHeader * ah = (AttributeHeader *)attr_data;
AttributeHeader *end = (AttributeHeader *)(attr_data + attr_data_len);
- AttributeS * attr;
+ AttributeS * attr;
m_logEntry.m_frag_id = frag_id;
while(ah < end){
- attr= m_logEntry.add_attr();
+ attr = m_logEntry.add_attr();
if(attr == NULL) {
ndbout_c("Restore: Failed to allocate memory");
res = -1;
@@ -1641,9 +1651,9 @@ RestoreLogIterator::getNextLogEntry(int
} else {
attr->Data.null = false;
attr->Data.void_value = ah->getDataPtr();
+ Twiddle(attr->Desc, &(attr->Data));
}
- Twiddle(attr->Desc, &(attr->Data));
ah = ah->getNext();
}
=== modified file 'storage/ndb/tools/restore/Restore.hpp'
--- a/storage/ndb/tools/restore/Restore.hpp 2008-09-19 06:45:00 +0000
+++ b/storage/ndb/tools/restore/Restore.hpp 2009-04-02 18:18:08 +0000
@@ -49,9 +49,6 @@ typedef void* (*AttrConvertFunc)(const
void *parameter);
// Forward declarations
-//class AttributeDesc;
-struct AttributeDesc;
-struct AttributeData;
struct AttributeS;
struct AttributeData {
@@ -324,7 +321,9 @@ public:
const char * getFilename() const { return m_fileName;}
Uint32 getNodeId() const { return m_nodeId;}
const BackupFormat::FileHeader & getFileHeader() const { return m_fileHeader;}
- bool Twiddle(const AttributeDesc * attr_desc, AttributeData * attr_data, Uint32 arraySize = 0);
+ bool Twiddle(const AttributeDesc * const attr_desc,
+ AttributeData * attr_data,
+ Uint32 arraySize = 0) const;
Uint64 get_file_size() const { return m_file_size; }
Uint64 get_file_pos() const { return m_file_pos; }
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20090402181808-m2e5vzn4z0umg20t.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.3 branch (magnus.blaudd:2923)Bug#39540 | Magnus Blåudd | 2 Apr 2009 |