Browse files

Fixed bug #59972 - Make body binary safe

  • Loading branch information...
1 parent 5793a7e commit 7d61983988c8a893bcf4531432346f11b29e96e2 @adoy adoy committed Nov 18, 2012
Showing with 6 additions and 6 deletions.
  1. +3 −3 php_stomp.c
  2. +3 −3 stomp.c
View
6 php_stomp.c
@@ -686,7 +686,7 @@ PHP_FUNCTION(stomp_send)
if (Z_TYPE_P(msg) == IS_STRING) {
frame.body = Z_STRVAL_P(msg);
- frame.body_length = -1;
+ frame.body_length = Z_STRLEN_P(msg);
} else if (Z_TYPE_P(msg) == IS_OBJECT && instanceof_function(Z_OBJCE_P(msg), stomp_ce_frame TSRMLS_CC)) {
zval *frame_obj_prop = NULL;
frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "command", sizeof("command")-1, 1 TSRMLS_CC);
@@ -697,7 +697,7 @@ PHP_FUNCTION(stomp_send)
frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "body", sizeof("body")-1, 1 TSRMLS_CC);
if (Z_TYPE_P(frame_obj_prop) == IS_STRING) {
frame.body = Z_STRVAL_P(frame_obj_prop);
- frame.body_length = -1;
+ frame.body_length = Z_STRLEN_P(frame_obj_prop);
}
frame_obj_prop = zend_read_property(stomp_ce_frame, msg, "headers", sizeof("headers")-1, 1 TSRMLS_CC);
if (Z_TYPE_P(frame_obj_prop) == IS_ARRAY) {
@@ -993,7 +993,7 @@ PHP_FUNCTION(stomp_read_frame)
array_init(return_value);
add_assoc_string_ex(return_value, "command", sizeof("command"), res->command, 1);
if (res->body) {
- add_assoc_string_ex(return_value, "body", sizeof("body"), res->body, 1);
+ add_assoc_stringl_ex(return_value, "body", sizeof("body"), res->body, res->body_length, 1);
}
add_assoc_zval_ex(return_value, "headers", sizeof("headers"), headers);
}
View
6 stomp.c
@@ -285,15 +285,15 @@ int stomp_send(stomp_t *stomp, stomp_frame_t *frame TSRMLS_DC)
}
if (frame->body_length > 0) {
- smart_str_appends(&buf, "content-length: ");
+ smart_str_appends(&buf, "content-length:");
smart_str_append_long(&buf, frame->body_length);
smart_str_appendc(&buf, '\n');
}
smart_str_appendc(&buf, '\n');
if (frame->body > 0) {
- smart_str_appends(&buf, frame->body);
+ smart_str_appendl(&buf, frame->body, frame->body_length > 0 ? frame->body_length : strlen(frame->body));
}
if (!stomp_writeable(stomp)) {
@@ -552,7 +552,7 @@ stomp_frame_t *stomp_read_frame(stomp_t *stomp)
}
/* Check for the content length */
- if (zend_hash_find(f->headers, "content-length", strlen("content-length"), (void **)&length_str) == SUCCESS) {
+ if (zend_hash_find(f->headers, "content-length", sizeof("content-length"), (void **)&length_str) == SUCCESS) {
char endbuffer[2];
length = 2;

0 comments on commit 7d61983

Please sign in to comment.