Issue tracker not working, so reporting a bug here ...

Jun 5, 2010 at 7:41 PM

In trying to read a prop_type_mv_long, I received an index out of bounds error in read_prop_array():

object.h, line 215:
    std::vector<byte> buffer = get_value_variable(id);
-->    return std::vector<T>((T*)&buffer[0], (T*)&buffer[buffer.size()]);

buffer[buffer.size()] is out of bounds

the buffer is:
-  buffer [12](3 '',0,0,0,0,0,0,0,3 '',0,0,0) std::vector<unsigned char,std::allocator<unsigned char> >
  [size] 12 unsigned long
  [capacity] 12 unsigned long
  [0] 3 '' unsigned char
  [1] 0 unsigned char
  [2] 0 unsigned char
  [3] 0 unsigned char
  [4] 0 unsigned char
  [5] 0 unsigned char
  [6] 0 unsigned char
  [7] 0 unsigned char
  [8] 3 '' unsigned char
  [9] 0 unsigned char
  [10] 0 unsigned char
  [11] 0 unsigned char

 

Coordinator
Jun 5, 2010 at 7:48 PM

What is up with Issue Tracker? Maybe we should report it to the codeplex people...

Anyway, that looks like a bug. Try replacing the line you quoted with:

    return std::vector<T>(reinterpret_cast<T*>(&buffer[0]), buffer.size()/sizeof(T));

Jun 5, 2010 at 7:56 PM

Dunno -- every time I try and report something, I get a codeplex error.  Does it work for you?

Jun 5, 2010 at 8:02 PM

That doesn't work either, btw.  sorry ...

1>e:\src\pstsdk_0_1\pstsdk\ltp\object.h(215): error C2665: 'std::vector<_Ty>::vector' : none of the 7 overloads could convert all the argument types
1>          with
1>          [
1>              _Ty=pstsdk::ulong
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(521): could be 'std::vector<_Ty>::vector(unsigned int,const _Ty &)'
1>          with
1>          [
1>              _Ty=pstsdk::ulong
1>          ]
1>          while trying to match the argument list '(pstsdk::ulong *, unsigned int)'
1>          e:\src\pstsdk_0_1\pstsdk\ltp\object.h(232) : see reference to function template instantiation 'std::vector<_Ty> pstsdk::const_property_object::read_prop_array<pstsdk::ulong>(pstsdk::prop_id) const' being compiled
1>          with
1>          [
1>              _Ty=pstsdk::ulong
1>          ]
1>e:\src\pstsdk_0_1\pstsdk\ltp\object.h(215): error C2665: 'std::vector<_Ty>::vector' : none of the 7 overloads could convert all the argument types
1>          with
1>          [
1>              _Ty=double
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(521): could be 'std::vector<_Ty>::vector(unsigned int,const _Ty &)'
1>          with
1>          [
1>              _Ty=double
1>          ]
1>          while trying to match the argument list '(double *, unsigned int)'
1>          e:\src\pstsdk_0_1\pstsdk\ltp\object.h(268) : see reference to function template instantiation 'std::vector<_Ty> pstsdk::const_property_object::read_prop_array<double>(pstsdk::prop_id) const' being compiled
1>          with
1>          [
1>              _Ty=double
1>          ]
1>e:\src\pstsdk_0_1\pstsdk\ltp\object.h(215): error C2665: 'std::vector<_Ty>::vector' : none of the 7 overloads could convert all the argument types
1>          with
1>          [
1>              _Ty=pstsdk::block_id
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\vector(521): could be 'std::vector<_Ty>::vector(unsigned int,const _Ty &)'
1>          with
1>          [
1>              _Ty=pstsdk::block_id
1>          ]
1>          while trying to match the argument list '(pstsdk::ulonglong *, unsigned int)'
1>          e:\src\pstsdk_0_1\pstsdk\ltp\object.h(275) : see reference to function template instantiation 'std::vector<_Ty> pstsdk::const_property_object::read_prop_array<pstsdk::ulonglong>(pstsdk::prop_id) const' being compiled
1>          with
1>          [
1>              _Ty=pstsdk::block_id
1>          ]

Coordinator
Jun 5, 2010 at 8:19 PM

Oops, std::vector doesn't have that constructor, sorry. My fault for not compiling before hitting "Post"..

Try:

    return std::vector<T>(reinterpret_cast<T*>(&buffer[0]), reinterpret_cast<T*>(&buffer[0] + buffer.size()));

This compiles, but unfortunately (and obviously) the unit test doesn't cover reading a multi valued long property type (only multivalued string props, apparently), so I'm not 100% certain this solves the problem entirely.

 

Jun 5, 2010 at 8:32 PM

I'm also having an issue with mv_guid, but I dunno if I'm doing it wrong ... code looks something like this:

    case prop_type_mv_guid:
      {
        vector<vector<pstsdk::byte>> arr = bag.read_prop_array<vector<pstsdk::byte>>(orig);
        // irrelevent stuff stripped
      }
      break;

read_prop_array<vector<pstsdk::byte>>(orig)  throws a "std::length" error every time.

object.h, line 301:

#ifdef PSTSDK_VALIDATION_LEVEL_WEAK
    if(buffer.size() < (sizeof(ulong) + ptoc->count * sizeof(ulong)))
-->        throw std::length_error("mv prop too short");
#endif

+  this 0x0071e20c {m_pbth=shared_ptr {m_heap=shared_ptr {m_node={...} } [1 strong ref, 1 weak ref] [default] m_id=96 m_level=0 } [1 strong ref] [default] } const pstsdk::const_property_object * const
  id 3678 unsigned short
-  buffer [16](184 '¸',221 'Ý',210 'Ò',133 '…',37 '%',98 'b',210 'Ò',17 '',189 '½',241 'ñ',0,192 'À',79 'O',214 'Ö',85 'U',181 'µ') std::vector<unsigned char,std::allocator<unsigned char> >
  [size] 16 unsigned long
  [capacity] 16 unsigned long
  [0] 184 '¸' unsigned char
  [1] 221 'Ý' unsigned char
  [2] 210 'Ò' unsigned char
  [3] 133 '…' unsigned char
  [4] 37 '%' unsigned char
  [5] 98 'b' unsigned char
  [6] 210 'Ò' unsigned char
  [7] 17 '' unsigned char
  [8] 189 '½' unsigned char
  [9] 241 'ñ' unsigned char
  [10] 0 unsigned char
  [11] 192 'À' unsigned char
  [12] 79 'O' unsigned char
  [13] 214 'Ö' unsigned char
  [14] 85 'U' unsigned char
  [15] 181 'µ' unsigned char
+  results [0]() std::vector<std::vector<unsigned char,std::allocator<unsigned char> >,std::allocator<std::vector<unsigned char,std::allocator<unsigned char> > > >
+  ptoc 0x03324b18 {count=2245189048 offsets=0x03324b1c } pstsdk::disk::mv_toc *

Coordinator
Jun 5, 2010 at 9:11 PM

You should just be calling read_prop_array<guid>, which returns a vector<guid>

Jun 5, 2010 at 9:40 PM

Nice!  I was confused, since I wasn't able to read_prop<guid>() -- it won't compile.  So I figured if I couldn't do read_prop<guid> I'd have little or no chance of doing read_prop_array<guid>

 

Coordinator
Jun 5, 2010 at 9:45 PM

Doh, read_prop<guid> should definitely compile..

Coordinator
Jun 6, 2010 at 2:12 PM

Try the latest from trunk

Jun 6, 2010 at 5:47 PM

Working nicely!  I'll be kicking the tires against a bunch of PST's and OST's over the coming week, several of them may be corrupt in some fashion or another.  Should be a good series of tests!  My code is iterating over every message, attachment, recipient and property for each.  I'm going to attempt to validate every prop by running the same MAPI code to open a copy of the same PST, and iterate through the store and compare every prop of every object.