Bug #69619 [Asn->Csd]: wrong argument for memcpy in from_zval_write_control
| From: | pollita@php.net | Date: | Wed, 17 Jun 2015 20:36:07 +0000 |
| Subject: | Bug #69619 [Asn->Csd]: wrong argument for memcpy in from_zval_write_control | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-193628@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69619&edit=1
ID: 69619
Updated by: pollita@php.net
Reported by: herumi at nifty dot com
Summary: wrong argument for memcpy in from_zval_write_control
-Status: Assigned
+Status: Closed
Type: Bug
Package: Sockets related
Operating System: all
PHP Version: 5.5.24
Assigned To: pollita
Block user comment: N
Private report: N
New Comment:
The fix for this bug has been committed.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2015-06-13 02:20:31] pollita@php.net
Thanks for confirming my thoughts! I'll merge this soon (unless you get to it first)
------------------------------------------------------------------------
[2015-06-07 04:22:20] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
------------------------------------------------------------------------
[2015-05-31 22:45:18] cataphract@php.net
I agree with everything.
The memcpy should be copying the value of the reallocated pointer, not the data it points to and in
fact the memset looks suspicious from the onset because you usually see memcpy(&foo, &bar,
sizeof(bar)), i.e., one extra level of indirection in the 2nd argument.
And yes the memset looks like it should start at ((char*)*control_buf) + *offset) (zero the newly
allocated segment).
I guess this branch was never exercised in the tests. Sorry for the trouble.
------------------------------------------------------------------------
[2015-05-30 16:15:56] pollita@php.net
In fact, that memset feels wrong as well. I would assume it wants to clear the >end< of the
buffer, not the beginning. Hence:
memset(*control_buf + *offset, '\0', *control_len - *offset);
------------------------------------------------------------------------
[2015-05-30 16:07:49] pollita@php.net
Looking at the code, your analysis certainly seems to be correct, and I'm happy enough to apply
the fix (including to prior supported branches), but I'd like to include a regression test. Do
you have some reproduce code for this?
I realize that the bug presents itself in the form of a leak, but developer builds usually have
--enable-debug turned on which produce leak warnings, so any repro which triggers the leak should
properly fail any test case which uses this code path.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=69619
--
Edit this bug report at https://bugs.php.net/bug.php?id=69619&edit=1