File tree 3 files changed +34
-3
lines changed
3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,10 @@ PHP NEWS
136
136
. Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with
137
137
bail enabled). (ilutov)
138
138
139
+ - SysVMsg:
140
+ . Fixed bug GH-16592 (msg_send() crashes when a type does not properly
141
+ serialized). (David Carlier / cmb)
142
+
139
143
- SysVShm:
140
144
. Fixed bug GH-16591 (Assertion error in shm_put_var). (nielsdos, cmb)
141
145
Original file line number Diff line number Diff line change @@ -371,11 +371,19 @@ PHP_FUNCTION(msg_send)
371
371
php_var_serialize (& msg_var , message , & var_hash );
372
372
PHP_VAR_SERIALIZE_DESTROY (var_hash );
373
373
374
+ if (UNEXPECTED (EG (exception ))) {
375
+ smart_str_free (& msg_var );
376
+ RETURN_THROWS ();
377
+ }
378
+
379
+
380
+ zend_string * str = smart_str_extract (& msg_var );
381
+ message_len = ZSTR_LEN (str );
374
382
/* NB: php_msgbuf is 1 char bigger than a long, so there is no need to
375
383
* allocate the extra byte. */
376
- messagebuffer = safe_emalloc (ZSTR_LEN ( msg_var . s ) , 1 , sizeof (struct php_msgbuf ));
377
- memcpy (messagebuffer -> mtext , ZSTR_VAL (msg_var . s ), ZSTR_LEN ( msg_var . s ) + 1 );
378
- message_len = ZSTR_LEN ( msg_var . s );
384
+ messagebuffer = safe_emalloc (message_len , 1 , sizeof (struct php_msgbuf ));
385
+ memcpy (messagebuffer -> mtext , ZSTR_VAL (str ), message_len + 1 );
386
+ zend_string_release_ex ( str , false );
379
387
smart_str_free (& msg_var );
380
388
} else {
381
389
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