Skip to content

Commit c2aafc8

Browse files
author
opencarthelp
committed
Protection from object injection in cart
opencart/opencart#1534
1 parent 56981bf commit c2aafc8

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

upload/system/library/cart.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function getProducts() {
265265
}
266266

267267
public function add($product_id, $qty = 1, $option = array()) {
268-
if (!$option) {
268+
if (!$option || !is_array($option)) {
269269
$key = (int)$product_id;
270270
} else {
271271
$key = (int)$product_id . ':' . base64_encode(serialize($option));
@@ -283,7 +283,7 @@ public function add($product_id, $qty = 1, $option = array()) {
283283
}
284284

285285
public function update($key, $qty) {
286-
if ((int)$qty && ((int)$qty > 0)) {
286+
if ((int)$qty && ((int)$qty > 0) && isset($this->session->data['cart'][$key])) {
287287
$this->session->data['cart'][$key] = (int)$qty;
288288
} else {
289289
$this->remove($key);

0 commit comments

Comments
 (0)