Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed $address is null in AddressController. #3373

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

kiatng
Copy link
Contributor

@kiatng kiatng commented Jul 11, 2023

Description (*)

I have this error log in a production instance:

Array
(
    [type] => 1:E_ERROR
    [message] => Uncaught Error: Call to a member function getId() on null in /app/code/core/Mage/Customer/controllers/AddressController.php:163
  thrown
    [file] => /app/code/core/Mage/Customer/controllers/AddressController.php
    [line] => 163
    [uri] => /customer/address/formPost/?form_key=llZ2YRTc7teqJ5qD&success_url=&error_url=&firstname=JEMS&middlename=STEV&lastname=LEO&company=%5C&telephone=%27&fax=%27&street%5B%5D=%27&street%5B%5D=%27&city=%27®ion_id=®ion=&postcode=*&country_id=AU&default_billing=1&default_shipping=1
)

Looking at the uri, it seems it's an attempt by some bad agent trying something. It needs to extract the form_key and test the server to reveal something.

This is because when line 99 $this->getRequest()->isPost() is false, $address is not defined:

public function formPostAction()
{
if (!$this->_validateFormKey()) {
return $this->_redirect('*/*/');
}
// Save data
if ($this->getRequest()->isPost()) {
$customer = $this->_getSession()->getCustomer();
/** @var Mage_Customer_Model_Address $address */
$address = Mage::getModel('customer/address');

Manual Testing

You can extract the form key and then attach the URI to your domain in the browser:

/customer/address/formPost/?form_key={replace with your key}&success_url=&error_url=&firstname=JEMS&middlename=STEV&lastname=LEO&company=%5C&telephone=%27&fax=%27&street%5B%5D=%27&street%5B%5D=%27&city=%27®ion_id=®ion=&postcode=*&country_id=AU&default_billing=1&default_shipping=1
)

The output depends on your server config.

@github-actions github-actions bot added the Component: Customer Relates to Mage_Customer label Jul 11, 2023
@fballiano fballiano merged commit c36f57d into OpenMage:main Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants