You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to decode a string, which is a b64encoded 64-byte signature, to a preallocated buffer.
Since its length is known exactly, it might not be a good practice to allocate a buffer bigger than that.
But the decoded_max_size requires 2 more bytes.
Is it possible to give a more precise calculation on the length of output?
If not, what about throw a concise exception?
$ valgrind ./main ==13588== Memcheck, a memory error detector==13588== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.==13588== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info==13588== Command: ./main==13588== 666424778d32d82a5aae7517e332665cfeb40e47cb0c612d21f70aafa04c5b3a33c8895a038d4fb2e5f6dd4dc07da6da10975a9a1e593f74c37f8b9081bfc0d6a212==13588== ==13588== Process terminating with default action of signal 6 (SIGABRT)==13588== at 0x5C84E97: raise (raise.c:51)==13588== by 0x5C86800: abort (abort.c:79)==13588== by 0x40472B: init<cppcodec::data::raw_result_buffer> (include/cppcodec/detail/../data/raw_result_buffer.hpp:61)==13588== by 0x40472B: void cppcodec::detail::codec<cppcodec::detail::base64<cppcodec::detail::base64_rfc4648> >::decode<cppcodec::data::raw_result_buffer>(cppcodec::data::raw_result_buffer&, char const*, unsigned long) (include/cppcodec/detail/codec.hpp:268)==13588== by 0x404659: cppcodec::detail::codec<cppcodec::detail::base64<cppcodec::detail::base64_rfc4648> >::decode(char*, unsigned long, char const*, unsigned long) (include/cppcodec/detail/codec.hpp:298)==13588== by 0x404618: unsigned long cppcodec::detail::codec<cppcodec::detail::base64<cppcodec::detail::base64_rfc4648> >::decode<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(char*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (include/cppcodec/detail/codec.hpp:314)==13588== by 0x401BD4: unsigned long cppcodec::detail::codec<cppcodec::detail::base64<cppcodec::detail::base64_rfc4648> >::decode<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(unsigned char*, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (include/cppcodec/detail/codec.hpp:307)==13588== by 0x4018AB: try_2() (main.cpp:26)==13588== by 0x401970: main (main.cpp:34)==13588== ==13588== HEAP SUMMARY:==13588== in use at exit: 89 bytes in 1 blocks==13588== total heap usage: 5 allocs, 4 frees, 74,012 bytes allocated==13588== ==13588== LEAK SUMMARY:==13588== definitely lost: 0 bytes in 0 blocks==13588== indirectly lost: 0 bytes in 0 blocks==13588== possibly lost: 0 bytes in 0 blocks==13588== still reachable: 89 bytes in 1 blocks==13588== suppressed: 0 bytes in 0 blocks==13588== Rerun with --leak-check=full to see details of leaked memory==13588== ==13588== For counts of detected and suppressed errors, rerun with: -v==13588== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)[1] 13588 abort (core dumped) valgrind ./main
I'm trying to decode a string, which is a b64encoded 64-byte signature, to a preallocated buffer.
Since its length is known exactly, it might not be a good practice to allocate a buffer bigger than that.
But the
decoded_max_size
requires 2 more bytes.Is it possible to give a more precise calculation on the length of output?
If not, what about throw a concise exception?
Here's my comiler
The text was updated successfully, but these errors were encountered: