[Tellico] Export to PilotDB broken?

Jens Seidel jensseidel at users.sf.net
Tue Feb 20 17:21:20 MST 2007


On Tue, Feb 20, 2007 at 11:36:05PM +0100, Jens Seidel wrote:
> On Tue, Feb 20, 2007 at 06:53:33AM -0800, Robby Stephenson wrote:
> > On Sunday 18 February 2007, Oscar Portela wrote:
> > > While exporting to PalmDB is supported, so far I have been able to make
> > > it work properly: it doesn't matter how little entries or fields I
> > > select, but every time I try to export them, Tellico starts using memory
> > > until it runs out of it, dying as a consequence having written nothing.
> 
> I tried the current subversion version from the branch tellico-1.2.x. It
> didn't hang for me but I got the following error in a valgrind session:
> 
> tellico: PilotDBExporter::exec() - encoding with UTF-8
> tellico: PilotDBExporter::data() - skipping Bild image field
> tellico: PilotDBExporter::data() - adding note
> ==7747==
> ==7747== Invalid read of size 4
> ==7747==    at 0x8208E68: Tellico::Export::PilotDB::data() (in /home/jens/local2/bin/tellico)
> ==7747==    by 0x81ABCDA: Tellico::Export::PilotDBExporter::exec() (in /home/jens/local2/bin/tellico)
> ==7747==    by 0x8088B17: Tellico::ExportDialog::exportURL(KURL const&) const (in /home/jens/local2/bin/tellico)
> ==7747==    by 0x80CC7CC: Tellico::MainWindow::slotFileExport(int) (in /home/jens/local2/bin/tellico)
> ==7747==    by 0x80CCBE2: Tellico::MainWindow::qt_invoke(int, QUObject*) (in /home/jens/local2/bin/tellico)

Oops, I forgot to activate debugging symbols.

The following patch fixes it but I'm not sure whether it caused any
problem except reading bogus data which is probably ignored:

Index: src/translators/pilotdb/pilotdb.cpp
===================================================================
--- src/translators/pilotdb/pilotdb.cpp	(Revision 1508)
+++ src/translators/pilotdb/pilotdb.cpp	(Arbeitskopie)
@@ -18,6 +18,7 @@
 #include <kdebug.h>
 
 #include <qbuffer.h>
+#include <algorithm>
 
 using namespace PalmLib;
 using Tellico::Export::PilotDB;
@@ -50,7 +51,9 @@
   pi_int16_t ent_hdr_size = isResourceDB() ? PI_RESOURCE_ENT_SIZE : PI_RECORD_ENT_SIZE;
   std::streampos offset = PI_HDR_SIZE + m_records.size() * ent_hdr_size + 2;
 
-  memcpy(buf, name().c_str(), 32);
+  for (int i=0; i<32; ++i)
+    buf[i] = 0;
+  memcpy(buf, name().c_str(), std::min(32-1, static_cast<int>(name().length())));
   set_short(buf + 32, flags());
   set_short(buf + 34, version());
   set_long(buf + 36, creation_time());

(I'm not sure whether the beginning of buf needs to be a null terminated
character string, that's why I subtract 1 to ensure it.)

Jens



More information about the tellico-users mailing list