PROTON-917: avoid buffer underrun if no mechs given

Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/718d8b37
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/718d8b37
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/718d8b37

Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 718d8b37644ab9102364ce8e23ee47b029191556
Parents: cbb6800
Author: Ken Giusti <kgiu...@apache.org>
Authored: Wed Jun 17 14:47:29 2015 -0400
Committer: Ken Giusti <kgiu...@apache.org>
Committed: Wed Jun 17 14:49:58 2015 -0400

----------------------------------------------------------------------
 proton-c/src/sasl/sasl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/718d8b37/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index 3142832..c339ea9 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -586,7 +586,10 @@ int pn_do_mechanisms(pn_transport_t *transport, uint8_t 
frame_type, uint16_t cha
       pn_string_addf(mechs, "%*s ", (int)s.size, s.start);
     }
   }
-  pn_string_buffer(mechs)[pn_string_size(mechs)-1] = 0;
+
+  if (pn_string_size(mechs)) {
+      pn_string_buffer(mechs)[pn_string_size(mechs)-1] = 0;
+  }
 
   if (pni_init_client(transport) &&
       pni_process_mechanisms(transport, pn_string_get(mechs))) {


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

Reply via email to