ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/CBOR-XS/doc/value-sharing.pod
(Generate patch)

Comparing CBOR-XS/doc/value-sharing.pod (file contents):
Revision 1.9 by root, Wed Nov 27 15:53:28 2019 UTC vs.
Revision 1.10 by root, Thu Sep 22 08:04:27 2022 UTC

48Subsequent occurrences can then be encoded by encoding the index 48Subsequent occurrences can then be encoded by encoding the index
49of a previously marked value tagged with the sharedref tag (value 49of a previously marked value tagged with the sharedref tag (value
50C<29>). That is, index 0 refers to the first value marked as 50C<29>). That is, index 0 refers to the first value marked as
51shareable in the CBOR stream, index 1 to the second and so on. 51shareable in the CBOR stream, index 1 to the second and so on.
52 52
53There is no requirement to actually refer to a value marked as 53Any taggable value can be marked for sharing, and there is no requirement
54shareable - encoders can mark any value they want without ever 54to actually refer to a value marked as shareable - encoders can mark any
55referring to them. 55value they want without ever referring to them.
56 56
57Implementors are advised that, to be able to encode cyclic structures, 57Implementors are advised that, to be able to encode cyclic structures,
58it must be possible to refer to a value before it is completely 58it must be possible to refer to a value before it is completely
59decoded. For example, during decoding of a map, some entries can 59decoded. For example, during decoding of a map, some entries can
60refer to the map being decoded. Thus an implementation cannot decode 60refer to the map being decoded. Thus an implementation cannot decode
150 d8 1c # tag(28) 150 d8 1c # tag(28)
151 81 # array(1) 151 81 # array(1)
152 d8 1d # tag(29) 152 d8 1d # tag(29)
153 00 # unsigned(0) 153 00 # unsigned(0)
154 154
155=head1 SECURITY CONSIDERATIONS
156
157Implementing this extension can open up a decoder for additional resource
158exhaustion attacks.
159
160The possibility to create cyclic data structures can create problems
161for implementtaions that rely on garbage collection to clean up data
162structures, and it could potentially lead to problems with algorithms that
163can't cope with this, leading to infinite loops or similar problems. One
164way to counter that is to not enable decoding of shared values by default,
165so code that wants it can opt-in. Another way would be to disallow
166decoding of cyclic data structures while still allowing other forms of
167shared values (for example, by tracking whether a referenced value has
168been fully decoded already and fail if not).
169
170Implementations that decode shared values by duplicating them could
171also suffer from excessive expansion (e.g. having a string referenced
172multiple times in an array, then having this array referenced multiple
173times in another array and so on). This is not usually a problem as most
174implementations already treat arrays and objects as references, and can
175therefore avoid duplication.
176
155=head1 IMPLEMENTATIONS 177=head1 IMPLEMENTATIONS
156 178
157This section lists known implementations of this extension (L<drop me a 179This section lists known implementations of this extension (L<drop me a
158mail|mailto:cbor@schmorp.de?Subject=CBOR-value-sharing> if you want to be 180mail|mailto:cbor@schmorp.de?Subject=CBOR-value-sharing> if you want to be
159listed here). 181listed here).
164 186
165=item * [JavaScript] L<borc-refs|https://github.com/sandhawke/borc-refs> 187=item * [JavaScript] L<borc-refs|https://github.com/sandhawke/borc-refs>
166 188
167=item * [Perl] L<CBOR::Free|https://metacpan.org/pod/CBOR::Free> 189=item * [Perl] L<CBOR::Free|https://metacpan.org/pod/CBOR::Free>
168 190
191=item * [Nodejs] L<node-cbor|https://github.com/hildjj/node-cbor/>
192
169=back 193=back
170 194

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines