You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2024/07/16 20:28:14 UTC
(qpid-proton) 01/02: PROTON-2838: Correctly handle null when decoding AMQP to raw
This is an automated email from the ASF dual-hosted git repository.
astitcher pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
commit 3b7610a6409f6f41461360bf5a18eb39e266b4eb
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Thu Jul 20 10:58:09 2023 -0400
PROTON-2838: Correctly handle null when decoding AMQP to raw
Also add in raw encoding
---
c/src/core/consumers.h | 6 +++---
c/src/core/emitters.h | 18 ++++++++++++++++++
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/c/src/core/consumers.h b/c/src/core/consumers.h
index 94d2a6e02..e9d685de7 100644
--- a/c/src/core/consumers.h
+++ b/c/src/core/consumers.h
@@ -265,9 +265,9 @@ static inline bool consume_single_value(pni_consumer_t* consumer, uint8_t* type)
static inline bool consume_raw(pni_consumer_t* consumer, pn_bytes_t* raw) {
size_t start = consumer->position;
- uint8_t dummy;
- bool succeed = consume_single_value(consumer, &dummy);
- if (succeed) {
+ uint8_t type;
+ bool succeed = consume_single_value(consumer, &type);
+ if (succeed && type!=PNE_NULL) {
*raw = (pn_bytes_t){.size=consumer->position-start, .start=(const char*)consumer->output_start+start};
} else {
*raw = (pn_bytes_t) {0, NULL};
diff --git a/c/src/core/emitters.h b/c/src/core/emitters.h
index 46cec39db..68ddeb9d0 100644
--- a/c/src/core/emitters.h
+++ b/c/src/core/emitters.h
@@ -159,6 +159,13 @@ static inline void pni_emitter_writev32(pni_emitter_t* emitter, const pn_bytes_t
emitter->position += value.size;
}
+static inline void pni_emitter_raw(pni_emitter_t* emitter, const pn_bytes_t raw)
+{
+ if (pni_emitter_remaining(emitter, raw.size))
+ memcpy(emitter->output_start+emitter->position, raw.start, raw.size);
+ emitter->position += raw.size;
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////////
static inline void emit_null(pni_emitter_t* emitter, pni_compound_context* compound) {
@@ -540,6 +547,17 @@ static inline void emit_copy(pni_emitter_t* emitter, pni_compound_context* compo
compound->count++;
}
+static inline void emit_raw(pni_emitter_t* emitter, pni_compound_context* compound, const pn_bytes_t bytes) {
+ if (bytes.size==0 || bytes.start == 0) {
+ emit_null(emitter, compound);
+ return;
+ }
+
+ emit_accumulated_nulls(emitter, compound);
+ pni_emitter_raw(emitter, bytes);
+ compound->count++;
+}
+
static inline void emit_multiple(pni_emitter_t* emitter, pni_compound_context* compound, pn_data_t* data) {
if (!data || pn_data_size(data) == 0) {
emit_null(emitter, compound);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org