tnef: Fix major issue iterating over attr streams
The original logic would read the count of attributes in the stream and then read the first attribute in the constructor of TnefAttributeStreamReader. Then the iterator interface would call ::rewind() before iterating to the first item. rewind() set the @pos attribute to zero, which would cause the attribute count (4-byte int) to be interpreted incorrectly as part of the first attribute. The new logic sets the position at 4 after rewind()ing, and does not read the first attribute twice. It also properly detects the end of the attribute stream by the number of attributes advertised as the first four bytes of the stream (read into the @count attribute initially).
Please register or sign in to comment