Bug #64109 [Asn->Opn]: incorrect use of abs() in array_pad()

From: Date: Tue, 24 Oct 2017 08:04:02 +0000
Subject: Bug #64109 [Asn->Opn]: incorrect use of abs() in array_pad()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212214@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=64109&edit=1 ID: 64109 Updated by: kalle@php.net Reported by: xi dot wang at gmail dot com Summary: incorrect use of abs() in array_pad() -Status: Assigned +Status: Open Type: Bug Package: Arrays related PHP Version: master-Git-2013-01-30 (Git) -Assigned To: laruence +Assigned To: Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2013-02-17 03:46:27] laruence@php.net actually, there are some other issues, like use abs on a long number. I am not sure whether this is a critical bug, but will try to fix it only for 5.4+ ------------------------------------------------------------------------ [2013-01-30 21:33:10] xi dot wang at gmail dot com Description: ------------ Using `abs(pad_size) < 0' to catch the LONG_MIN case invokes undefined behavior in C. gcc simply assumes abs(pad_size) must be non-negative and discards the check. Test script: --------------- <?php // This is for 64-bit systems. $input = array(12, 10, 9); $input = array_pad($input, -9223372036854775808, 0); var_dump($input); ?> Expected result: ---------------- Warning: array_pad(): You may only pad up to 1048576 elements at a time in t.php on line 3 bool(false) Actual result: -------------- array(3) { [0]=> int(12) [1]=> int(10) [2]=> int(9) } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64109&edit=1

« previous php.bugs (#212214) next »