TASTE bugtrack - Taste
View Issue Details
0000887Taste[All Projects] ASN.1 Compiler v4public2019-11-06 20:242020-08-31 15:32
shd01 
gmamais 
urgentmajoralways
closedfixed 
0000887: Encoding functions assume input buffers are initialised to zero
The bitstream functions in asn1crt.c (e.g. BitStream_AppendByte) use a logical OR to write into the supplied bitstream buffer. If that buffer was previously used to encode a different message, the result is the logical OR of the two messages. This was an absolute bear to track down. Please fix it soon.
No tags attached.
Issue History
2019-11-06 20:24shd01New Issue
2019-11-06 21:03maximeAssigned To => gmamais
2019-11-06 21:03maximeStatusnew => assigned
2019-11-07 07:50gmamaisNote Added: 0003663
2019-11-07 08:31shd01Note Added: 0003664
2019-11-07 08:36shd01Note Added: 0003665
2019-11-07 08:37shd01Note Deleted: 0003665
2019-11-07 08:49shd01Note Added: 0003666
2019-11-07 16:49gmamaisNote Added: 0003669
2019-11-10 19:27gmamaisNote Added: 0003674
2019-11-10 19:27gmamaisStatusassigned => resolved
2019-11-10 19:27gmamaisResolutionopen => fixed
2020-08-31 15:32maximeStatusresolved => closed

Notes
(0003663)
gmamais   
2019-11-07 07:50   
Is it possible to call the BitStream_Init() function before starting the encoding process? Please note that this was a design choice. It is much more efficient to call BitStream_Init  at the beginning to zero the output buffer instead of writing bit zeros in every call BitStream_AppendByte()  and BitStream_AppendPartialByte()
(0003664)
shd01   
2019-11-07 08:31   
Ah, I see. I can call the BitStream_Init().
(0003666)
shd01   
2019-11-07 08:49   
But I don't think that zeroing during write is particularly inefficent. Every byte is already accessed at least once, so instead of doing: a) buf[i] = buf[i] | newbits you could do: b) buf[i] = (buf[i] & mask) | newbits I think you'd be hard-pressed to notice an efficiency difference between the two.
(0003669)
gmamais   
2019-11-07 16:49   
You are right. There should no actual difference between the two. It will be implemented the way you propose.
(0003674)
gmamais   
2019-11-10 19:27   
fixed in latest GitHub commit (version 4.2.0.7)