Skip to content

Fix the bug where clone curl does not copy POST fields. - #16556

Open
matyhtf wants to merge 1 commit into
php:masterfrom
matyhtf:fix-curl-handle-clone
Open

Fix the bug where clone curl does not copy POST fields.#16556
matyhtf wants to merge 1 commit into
php:masterfrom
matyhtf:fix-curl-handle-clone

Conversation

@matyhtf

@matyhtf matyhtf commented Oct 23, 2024

Copy link
Copy Markdown
Contributor

No description provided.

@cmb69 cmb69 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

I think this also affects older PHP branches; should likely target PHP-8.2.

Comment thread ext/curl/interface.c Outdated
postfields = &clone_ch->postfields;
postfields = &ch->postfields;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the actual problem that we don't clone the ->postfields in the first place? I.e. ZVAL_COPY(&clone_ch->postfields, &ch->postfields).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code should behave consistently with PHP_FUNCTION(curl_copy_handle), with the only difference being the return value. This PR primarily aims to fix this bug, and a subsequent PR for code optimization can be submitted to implement a reusable function.

https://github.com/php/php-src/blob/5d10a33479c5a9bd71084f25a0b8e244ef7299da/ext/curl/interface.c#L1598

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you clone an object, you should clone all its properties.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have modified the code to use ZVAL_COPY for postfields and updated PHP_FUNCTION(curl_copy_handle) to ensure consistency with the clone operation.

@matyhtf
matyhtf force-pushed the fix-curl-handle-clone branch from 5d10a33 to a0dd445 Compare November 26, 2024 08:44
@matyhtf

matyhtf commented Nov 26, 2024

Copy link
Copy Markdown
Contributor Author

Updated

@Sjord

Sjord commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

#19813

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants