File tree 2 files changed +30
-3
lines changed
2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -370,11 +370,19 @@ PHP_FUNCTION(msg_send)
370
370
php_var_serialize (& msg_var , message , & var_hash );
371
371
PHP_VAR_SERIALIZE_DESTROY (var_hash );
372
372
373
+ if (UNEXPECTED (EG (exception ))) {
374
+ smart_str_free (& msg_var );
375
+ RETURN_THROWS ();
376
+ }
377
+
378
+
379
+ zend_string * str = smart_str_extract (& msg_var );
380
+ message_len = ZSTR_LEN (str );
373
381
/* NB: php_msgbuf is 1 char bigger than a long, so there is no need to
374
382
* allocate the extra byte. */
375
- messagebuffer = safe_emalloc (ZSTR_LEN ( msg_var . s ) , 1 , sizeof (struct php_msgbuf ));
376
- memcpy (messagebuffer -> mtext , ZSTR_VAL (msg_var . s ), ZSTR_LEN ( msg_var . s ) + 1 );
377
- message_len = ZSTR_LEN ( msg_var . s );
383
+ messagebuffer = safe_emalloc (message_len , 1 , sizeof (struct php_msgbuf ));
384
+ memcpy (messagebuffer -> mtext , ZSTR_VAL (str ), message_len + 1 );
385
+ zend_string_release_ex ( str , false );
378
386
smart_str_free (& msg_var );
379
387
} else {
380
388
char * p ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ msg_send() segfault when the type does not serialize as expected
3
+ --EXTENSIONS--
4
+ sysvmsg
5
+ --FILE--
6
+ <?php
7
+ class Test {
8
+ function __serialize () {}
9
+ }
10
+
11
+ $ q = msg_get_queue (1 );
12
+ try {
13
+ msg_send ($ q , 1 , new Test , true );
14
+ } catch (\TypeError $ e ) {
15
+ echo $ e ->getMessage ();
16
+ }
17
+ ?>
18
+ --EXPECT--
19
+ Test::__serialize() must return an array
You can’t perform that action at this time.
0 commit comments