php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch php5-stomp-only-binary-content-length.diff for stomp Bug #70280

Patch version 2015-08-18 09:05 UTC

Return to Bug #70280 | Download this patch
Patch Revisions:

Developer: vitalif@mail.ru

Patch for php5-stomp bug https://bugs.php.net/bug.php?id=70280
Only add 'content-length' header when message contains zero byte,
to allow for proper casting to JMS TextMessage in JMS/STOMP brokers.

--- a/php_stomp.c	2015-08-17 13:35:16.606295155 +0300
+++ b/php_stomp.c	2015-08-17 13:37:31.502299440 +0300
@@ -531,6 +531,7 @@ PHP_FUNCTION(stomp_connect)
 
 	if (stomp->status) {
 		stomp_frame_t *res;
+		int rres;
 		stomp_frame_t frame = {0};
  
 		INIT_FRAME(frame, "CONNECT");
@@ -549,9 +550,9 @@ PHP_FUNCTION(stomp_connect)
 			FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers));
 		}
 
-		res = stomp_send(stomp, &frame TSRMLS_CC);
+		rres = stomp_send(stomp, &frame TSRMLS_CC);
 		CLEAR_FRAME(frame);
-		if (0 == res) {
+		if (0 == rres) {
 			zval *excobj = zend_throw_exception_ex(stomp_ce_exception, stomp->errnum TSRMLS_CC, stomp->error);
 			if (stomp->error_details) {
 				zend_update_property_string(stomp_ce_exception, excobj, "details", sizeof("details")-1, stomp->error_details TSRMLS_CC);
@@ -746,6 +747,8 @@ PHP_FUNCTION(stomp_send)
 		CLEAR_FRAME(frame);
 		RETURN_FALSE;
 	}
+	if (frame.body_length > 0 && strnlen(frame.body, frame.body_length) >= frame.body_length)
+		frame.body_length = 0;
 
 	if (stomp_send(stomp, &frame TSRMLS_CC) > 0) {
 		success = stomp_valid_receipt(stomp, &frame);
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 23:01:30 2019 UTC