We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug Calling cbor_serialize_alloc() to serialize an empty byte string returns an error in libcbor 0.10.0. The problem appears related to https://github.com/PJK/libcbor/blob/master/src/cbor/internal/memory_utils.c#L37 called from https://github.com/PJK/libcbor/blob/master/src/cbor/serialization.c#L79.
To Reproduce The following snippet illustrates the problem:
#include <cbor.h> #include <err.h> #include <stdio.h> #include <stdlib.h> int main(void) { cbor_item_t *blob; unsigned char *cbor; size_t cbor_len; size_t cbor_alloc_len; if ((blob = cbor_build_bytestring(NULL, 0)) == NULL) errx(1, "cbor_build_bytestring"); if ((cbor_len = cbor_serialize_alloc(blob, &cbor, &cbor_alloc_len)) == 0) errx(1, "cbor_serialize_alloc"); for (size_t i = 0; i < cbor_len; i++) { printf("%02x ", cbor[i]); } printf("\n"); }
Expected behavior cbor_serialize_alloc() should succeed and return 0x40 (an empty byte string).
Environment libcbor 0.10.0 on Linux. Built by hand with default settings and clang-15.
The text was updated successfully, but these errors were encountered:
You're right, the zero-length strings cause signaling 0 to propagate even though it shouldn't. Thank you for the lightning fast report!
Sorry, something went wrong.
PJK
Successfully merging a pull request may close this issue.
Describe the bug
Calling cbor_serialize_alloc() to serialize an empty byte string returns an error in libcbor 0.10.0. The problem appears related to https://github.com/PJK/libcbor/blob/master/src/cbor/internal/memory_utils.c#L37 called from https://github.com/PJK/libcbor/blob/master/src/cbor/serialization.c#L79.
To Reproduce
The following snippet illustrates the problem:
Expected behavior
cbor_serialize_alloc() should succeed and return 0x40 (an empty byte string).
Environment
libcbor 0.10.0 on Linux. Built by hand with default settings and clang-15.
The text was updated successfully, but these errors were encountered: