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 2021/10/29 19:41:14 UTC

[qpid-proton] branch main updated (0d60a23 -> f34c8a2)

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git.


    from 0d60a23  PROTON-2382: An accessor on tracker for the delivery tag
     new 7ba9ef7  PROTON-2443: Workaround bug in cyrus sasl EXTERNAL mechanism
     new 3d6c8c4  PROTON-2444: Fix potential use of uninitialised value
     new 7e0edf4  PROTON-2445: Allow encoder to produce the short forms for 0
     new f34c8a2  PROTON-2446: escape quotemarks when they appear in dumped data

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 c/src/core/encoder.c                |  9 +++++++--
 c/src/core/util.c                   |  6 +++---
 c/src/sasl/cyrus_sasl.c             | 18 +++++++++++++++++-
 python/tests/proton_tests/engine.py | 12 ++++++------
 4 files changed, 33 insertions(+), 12 deletions(-)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-proton] 02/04: PROTON-2444: Fix potential use of uninitialised value

Posted by as...@apache.org.
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 3d6c8c4d21070af86c8c130e119257cfdc30e6fe
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Oct 27 17:56:16 2021 -0400

    PROTON-2444: Fix potential use of uninitialised value
---
 c/src/core/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/c/src/core/util.c b/c/src/core/util.c
index bed2a54..70a3fe6 100644
--- a/c/src/core/util.c
+++ b/c/src/core/util.c
@@ -98,7 +98,7 @@ int pn_strcasecmp(const char *a, const char *b)
 int pn_strncasecmp(const char* a, const char* b, size_t len)
 {
   int diff = 0;
-  while (*b && len > 0) {
+  while (len > 0 && *b) {
     char aa = *a++, bb = *b++;
     diff = tolower(aa)-tolower(bb);
     if ( diff!=0 ) return diff;

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-proton] 01/04: PROTON-2443: Workaround bug in cyrus sasl EXTERNAL mechanism

Posted by as...@apache.org.
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 7ba9ef7d446a6f3d6fcce12e854d09b4bd672db9
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Oct 27 17:56:57 2021 -0400

    PROTON-2443: Workaround bug in cyrus sasl EXTERNAL mechanism
    
    The mechanism plugin assumes that the initial iresponse data is zero
    terminated. But this is not required by the protocol or by the API used
    by cyrus sasl.
---
 c/src/sasl/cyrus_sasl.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/c/src/sasl/cyrus_sasl.c b/c/src/sasl/cyrus_sasl.c
index 6b34eaa..62d3427 100644
--- a/c/src/sasl/cyrus_sasl.c
+++ b/c/src/sasl/cyrus_sasl.c
@@ -180,7 +180,7 @@ static int pni_authorize(sasl_conn_t *conn,
     const char *def_realm, unsigned urlen,
     struct propctx *propctx)
 {
-  PN_LOG_DEFAULT(PN_SUBSYSTEM_SASL, PN_LEVEL_TRACE, "Authorized: userid=%*s by authuser=%*s @ %*s",
+  PN_LOG_DEFAULT(PN_SUBSYSTEM_SASL, PN_LEVEL_TRACE, "Authorized: userid=%.*s by authuser=%.*s @ %.*s",
     rlen, requested_user,
     alen, auth_identity,
     urlen, def_realm);
@@ -468,21 +468,37 @@ static int pni_wrap_server_start(pn_transport_t *transport, const char *mech_sel
     sasl_conn_t *cyrus_conn = (sasl_conn_t*)pnx_sasl_get_context(transport);
     const char *in_bytes = in->start;
     size_t in_size = in->size;
+    char buffer[128]; // scratch  buffer for zero termination
+    char *to_free = NULL;
     // Interop hack for ANONYMOUS - some of the earlier versions of proton will send and no data
     // with an anonymous init because it is optional. It seems that Cyrus wants an empty string here
     // or it will challenge, which the earlier implementation is not prepared for.
     // However we can't just always use an empty string as the CRAM-MD5 mech won't allow any data in the server start
+    // Also the EXTERNAL mech has a bug that ignores the size of the initial response string and expects it to be zero
+    // terminated, so make sure it is!
     if (!in_bytes && strcmp(mech_selected, "ANONYMOUS")==0) {
         in_bytes = "";
         in_size = 0;
     } else if (in_bytes && strcmp(mech_selected, "CRAM-MD5")==0) {
         in_bytes = 0;
         in_size = 0;
+    } else if (in_size && strcmp(mech_selected, "EXTERNAL")==0) {
+      char *b = buffer;
+      if (in_size>=128) {
+        to_free = malloc(in_size+1);
+        b = to_free;
+      }
+      if (b) {
+        memcpy(b, in_bytes, in_size);
+        b[in_size] = 0;
+        in_bytes = b;
+      }
     }
     result = sasl_server_start(cyrus_conn,
                                mech_selected,
                                in_bytes, in_size,
                                &out, &outlen);
+    free(to_free);
 
     pnx_sasl_set_bytes_out(transport, pn_bytes(outlen, out));
     return result;

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-proton] 03/04: PROTON-2445: Allow encoder to produce the short forms for 0

Posted by as...@apache.org.
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 7e0edf421a738fef6e17894f5ab6363ae4a38c5c
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Mon Sep 20 17:58:04 2021 -0400

    PROTON-2445: Allow encoder to produce the short forms for 0
    
    Previously (for reasons unknown) the AMQP type encoder never generated
    the short typecodes for ulong and uint 0. Using these instead of
    SMALLUINT and SMALLULONG saves a byte for each encoding.
    
    [Had to fix a few python tests which have the exact bytes of expected
    frames hardcoded in them]
---
 c/src/core/encoder.c                |  9 +++++++--
 python/tests/proton_tests/engine.py | 12 ++++++------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/c/src/core/encoder.c b/c/src/core/encoder.c
index 472ea3b..44722ef 100644
--- a/c/src/core/encoder.c
+++ b/c/src/core/encoder.c
@@ -99,13 +99,17 @@ static uint8_t pn_node2code(pn_encoder_t *encoder, pni_node_t *node)
       return PNE_INT;
     }
   case PN_ULONG:
-    if (node->atom.u.as_ulong < 256) {
+    if (node->atom.u.as_ulong == 0) {
+      return PNE_ULONG0;
+    } else if (node->atom.u.as_ulong < 256) {
       return PNE_SMALLULONG;
     } else {
       return PNE_ULONG;
     }
   case PN_UINT:
-    if (node->atom.u.as_uint < 256) {
+    if (node->atom.u.as_uint == 0) {
+      return PNE_UINT0;
+    } else if (node->atom.u.as_uint < 256) {
       return PNE_SMALLUINT;
     } else {
       return PNE_UINT;
@@ -290,6 +294,7 @@ static int pni_encoder_enter(void *ctx, pn_data_t *data, pni_node_t *node)
   case PNE_SMALLINT: pn_encoder_writef8(encoder, atom->u.as_int); return 0;
   case PNE_INT: pn_encoder_writef32(encoder, atom->u.as_int); return 0;
   case PNE_UTF32: pn_encoder_writef32(encoder, atom->u.as_char); return 0;
+  case PNE_ULONG0: return 0;
   case PNE_ULONG: pn_encoder_writef64(encoder, atom->u.as_ulong); return 0;
   case PNE_SMALLULONG: pn_encoder_writef8(encoder, atom->u.as_ulong); return 0;
   case PNE_LONG: pn_encoder_writef64(encoder, atom->u.as_long); return 0;
diff --git a/python/tests/proton_tests/engine.py b/python/tests/proton_tests/engine.py
index 586f974..6838d67 100644
--- a/python/tests/proton_tests/engine.py
+++ b/python/tests/proton_tests/engine.py
@@ -922,10 +922,10 @@ class TransferTest(Test):
         # Confirm abort discards the sender's buffered content, i.e. no data in generated transfer frame.
         # We want:
         # @transfer(20) [handle=0, delivery-id=0, delivery-tag=b"tag", message-format=0, settled=true, aborted=true]
-        wanted = b"\x00\x00\x00%\x02\x00\x00\x00\x00S\x14\xd0\x00\x00\x00\x15\x00\x00\x00\nR\x00R\x00\xa0\x03tagR\x00A@@@@A"
+        wanted = b'\x00\x00\x00"\x02\x00\x00\x00\x00S\x14\xd0\x00\x00\x00\x12\x00\x00\x00\nCC\xa0\x03tagCA@@@@A'
         t = self.snd.transport
         wire_bytes = t.peek(1024)
-        assert wanted == wire_bytes
+        assert wanted == wire_bytes, wire_bytes
 
         self.pump()
         assert self.rcv.current.aborted
@@ -1318,10 +1318,10 @@ class MaxFrameTransferTest(Test):
         assert sd.aborted
         # Expect a single abort transfer frame with no content.  One credit is consumed.
         # @transfer(20) [handle=0, delivery-id=0, delivery-tag=b"tag_1", message-format=0, settled=true, aborted=true]
-        wanted = b"\x00\x00\x00\x27\x02\x00\x00\x00\x00S\x14\xd0\x00\x00\x00\x17\x00\x00\x00\nR\x00R\x00\xa0\x05tag_1R\x00A@@@@A"
+        wanted = b'\x00\x00\x00\x24\x02\x00\x00\x00\x00S\x14\xd0\x00\x00\x00\x14\x00\x00\x00\nCC\xa0\x05tag_1CA@@@@A'
         t = self.snd.transport
         wire_bytes = t.peek(2048)
-        assert wanted == wire_bytes
+        assert wanted == wire_bytes, wire_bytes
         assert self.snd.credit == 0
         self.pump()
         assert self.rcv.current.aborted
@@ -1329,9 +1329,9 @@ class MaxFrameTransferTest(Test):
         self.snd.close()
         # Expect just the detach frame.
         # @detach(22) [handle=0, closed=true]
-        wanted = b"\x00\x00\x00\x17\x02\x00\x00\x00\x00S\x16\xd0\x00\x00\x00\x07\x00\x00\x00\x02R\x00A"
+        wanted = b"\x00\x00\x00\x16\x02\x00\x00\x00\x00S\x16\xd0\x00\x00\x00\x06\x00\x00\x00\x02CA"
         wire_bytes = t.peek(2048)
-        assert wanted == wire_bytes
+        assert wanted == wire_bytes, wire_bytes
 
 
 class IdleTimeoutTest(Test):

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-proton] 04/04: PROTON-2446: escape quotemarks when they appear in dumped data

Posted by as...@apache.org.
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 f34c8a251da84a6c6f9a5ba03e746e8ee60ee6a3
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Wed Oct 6 23:03:30 2021 -0400

    PROTON-2446: escape quotemarks when they appear in dumped data
---
 c/src/core/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/c/src/core/util.c b/c/src/core/util.c
index 70a3fe6..ced44ae 100644
--- a/c/src/core/util.c
+++ b/c/src/core/util.c
@@ -40,8 +40,8 @@ ssize_t pn_quote_data(char *dst, size_t capacity, const char *src, size_t size)
   for (unsigned i = 0; i < size; i++)
   {
     uint8_t c = src[i];
-    // output printable ASCII, ensure '\' always introduces hex escape
-    if (c < 128 && c != '\\' && isprint(c)) {
+    // output printable ASCII, ensure '\' always introduces hex escape, escape quote marks
+    if (c < 128 && c != '\\' && c != '\"' && c != '\'' && isprint(c)) {
       if (idx < (int) (capacity - 1)) {
         dst[idx++] = c;
       } else {

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org