[Libpst-devel] size_t fields

Chris Halls chris.halls at credativ.co.uk
Mon Jan 29 21:00:22 CET 2007


Hi

We have a problem with the attachment->size field. It's a 32 bit integer in 
the PST file but is a size_t in libpst.h. That means on a 64 bit machine you 
have difference sizes when doing a memcpy of size sizeof(size_t).

To fix this we can either change the size field to be of type int32_t or 
convert to 64 bit when setting the field. I reckon it is better to keep the 
size_t field and do the conversion when reading the PST file:

-       memcpy(&(attach->size), list->items[x]->data, 
-              sizeof(attach->size));
+       t = (*(int32_t*)list->items[x]->data);
+       LE32_CPU(t);
+       attach->size = t;

That way we keep the original ABI, the size_t field is the preferred type for 
the processor and we have room for expansion later should it become possible 
to attach files > 2GB in the future.

I've checked in this fix on r86, along with some other memory management fixes 
for errors that valgrind picked up.

There are a few more size_t fields in libpst.h so I guess we might need to do 
a similar thing there too.

Chris



More information about the Libpst-devel mailing list