summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/a_int.c
diff options
context:
space:
mode:
authorjsing <>2022-08-20 17:55:08 +0000
committerjsing <>2022-08-20 17:55:08 +0000
commit8ac1b2953068d5c968e516c4bd4ab89d61c5f3d6 (patch)
tree89a2da2d04ce101edf0271b14ed00f7b9bc2022e /src/lib/libcrypto/asn1/a_int.c
parent95b7defd486f5736d9f91a6f71156c20f91756e9 (diff)
downloadopenbsd-8ac1b2953068d5c968e516c4bd4ab89d61c5f3d6.tar.gz
openbsd-8ac1b2953068d5c968e516c4bd4ab89d61c5f3d6.tar.bz2
openbsd-8ac1b2953068d5c968e516c4bd4ab89d61c5f3d6.zip
Make it possible to signal an error from an i2c_* function.
In asn1_i2d_ex_primitive(), asn1_ex_i2c() returning -1 is used to indicate that the object is optional and should be skipped, while -2 is used to indicate that indefinite length encoding should be used. Any other negative value was treated as success, resulting in the out pointer being walked backwards. Avoid this by treating any negative value (aside from -1 and -2) as a failure, propagating it up the stack. Additionally, check the return value of the second asn1_ex_i2c() call to ensure that it matches the value returned by the first call. This makes sure that the length of the encoded object is correct, plus it detects the case where a failure occurs during the second call. Discussed with tb@ (who also flagged the negative value issue).
Diffstat (limited to 'src/lib/libcrypto/asn1/a_int.c')
0 files changed, 0 insertions, 0 deletions