php / php/php-src

stack overflow in array/sanitizer

Aperta
#23,112 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Extension: standard Status: Needs Triage
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

Description

The following code:

<?php
$a=[]; for($i=0;$i<1000000;$i++){$a=['k'=>$a];}
$b=array_merge_recursive($a,$a);

Resulted in this output:

    #226 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #227 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #228 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #229 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #230 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #231 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #232 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #233 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #234 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #235 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #236 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #237 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #238 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #239 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #240 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #241 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #242 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #243 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #244 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #245 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #246 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #247 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #248 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975
    #249 0x55fe77cec009 in php_array_merge_recursive /home/php-src/ext/standard/array.c:3975

SUMMARY: AddressSanitizer: stack-overflow ../../../../src/libsanitizer/asan/asan_stack.cpp:63 in __sanitizer::BufferedStackTrace::UnwindImpl(unsigned long, unsigned long, void*, bool, unsigned int)
==26==ABORTING
USE_ZEND_ALLOC=0 php poc.php
PHP Version
8.6.0
Operating System

ubuntu 22.04

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con il reproducer nell’issue e ispeziona php_array_merge_recursive in ext/standard/array.c:3975. Eseguilo con AddressSanitizer e USE_ZEND_ALLOC=0, quindi aggiungi un test di regressione che copra il caso annidato di array_merge_recursive; il lavoro è completato quando il reproducer non causa più un overflow dello stack.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, php
Ambito
backend, testing-qa
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.