@@ -329,9 +329,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
329
329
if (error ) {
330
330
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
331
331
}
332
- php_stream_close (fp );
333
- phar_destroy_phar_data (myphar );
334
- return FAILURE ;
332
+ goto bail ;
335
333
}
336
334
}
337
335
@@ -341,9 +339,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
341
339
if (error ) {
342
340
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
343
341
}
344
- php_stream_close (fp );
345
- phar_destroy_phar_data (myphar );
346
- return FAILURE ;
342
+ goto bail ;
347
343
}
348
344
349
345
hdr = (tar_header * ) buf ;
@@ -369,9 +365,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
369
365
if (error ) {
370
366
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (invalid entry size)" , fname );
371
367
}
372
- php_stream_close (fp );
373
- phar_destroy_phar_data (myphar );
374
- return FAILURE ;
368
+ goto bail ;
375
369
}
376
370
entry .filename = zend_string_alloc (entry .uncompressed_filesize , myphar -> is_persistent );
377
371
if (myphar -> is_persistent ) {
@@ -385,9 +379,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
385
379
if (error ) {
386
380
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
387
381
}
388
- php_stream_close (fp );
389
- phar_destroy_phar_data (myphar );
390
- return FAILURE ;
382
+ goto bail ;
391
383
}
392
384
393
385
/* skip blank stuff */
@@ -400,9 +392,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
400
392
if (error ) {
401
393
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
402
394
}
403
- php_stream_close (fp );
404
- phar_destroy_phar_data (myphar );
405
- return FAILURE ;
395
+ goto bail ;
406
396
}
407
397
408
398
read = php_stream_read (fp , buf , sizeof (buf ));
@@ -412,9 +402,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
412
402
if (error ) {
413
403
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
414
404
}
415
- php_stream_close (fp );
416
- phar_destroy_phar_data (myphar );
417
- return FAILURE ;
405
+ goto bail ;
418
406
}
419
407
continue ;
420
408
} else if (!last_was_longlink && !old && hdr -> prefix [0 ] != 0 ) {
@@ -474,9 +462,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
474
462
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (checksum mismatch of file \"%s\")" , fname , ZSTR_VAL (entry .filename ));
475
463
}
476
464
zend_string_release_ex (entry .filename , myphar -> is_persistent );
477
- php_stream_close (fp );
478
- phar_destroy_phar_data (myphar );
479
- return FAILURE ;
465
+ goto bail ;
480
466
}
481
467
482
468
uint32_t entry_mode = phar_tar_oct_number (hdr -> mode , sizeof (hdr -> mode ));
@@ -507,9 +493,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
507
493
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file - hard link to non-existent file \"%.*s\"" , fname , (int )linkname_len , hdr -> linkname );
508
494
}
509
495
zend_string_release_ex (entry .filename , myphar -> is_persistent );
510
- php_stream_close (fp );
511
- phar_destroy_phar_data (myphar );
512
- return FAILURE ;
496
+ goto bail ;
513
497
}
514
498
entry .link = estrndup (hdr -> linkname , linkname_len );
515
499
} else if (entry .tar_type == TAR_SYMLINK ) {
@@ -529,9 +513,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
529
513
if (error ) {
530
514
spprintf (error , 4096 , "phar error: tar-based phar \"%s\" has invalid metadata in magic file \"%s\"" , fname , ZSTR_VAL (entry .filename ));
531
515
}
532
- php_stream_close (fp );
533
- phar_destroy_phar_data (myphar );
534
- return FAILURE ;
516
+ goto bail ;
535
517
}
536
518
}
537
519
@@ -541,9 +523,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
541
523
if (error ) {
542
524
spprintf (error , 4096 , "phar error: tar-based phar \"%s\" has alias that is larger than 511 bytes, cannot process" , fname );
543
525
}
544
- php_stream_close (fp );
545
- phar_destroy_phar_data (myphar );
546
- return FAILURE ;
526
+ goto bail ;
547
527
}
548
528
549
529
read = php_stream_read (fp , buf , size );
@@ -562,9 +542,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
562
542
spprintf (error , 4096 , "phar error: invalid alias \"%s\" in tar-based phar \"%s\"" , buf , fname );
563
543
}
564
544
565
- php_stream_close (fp );
566
- phar_destroy_phar_data (myphar );
567
- return FAILURE ;
545
+ goto bail ;
568
546
}
569
547
570
548
actual_alias = pestrndup (buf , size , myphar -> is_persistent );
@@ -576,9 +554,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
576
554
spprintf (error , 4096 , "phar error: Unable to read alias from tar-based phar \"%s\"" , fname );
577
555
}
578
556
579
- php_stream_close (fp );
580
- phar_destroy_phar_data (myphar );
581
- return FAILURE ;
557
+ goto bail ;
582
558
}
583
559
}
584
560
@@ -592,9 +568,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
592
568
if (error ) {
593
569
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
594
570
}
595
- php_stream_close (fp );
596
- phar_destroy_phar_data (myphar );
597
- return FAILURE ;
571
+ goto bail ;
598
572
}
599
573
}
600
574
@@ -609,9 +583,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
609
583
if (error ) {
610
584
spprintf (error , 4096 , "phar error: \"%s\" is a corrupted tar file (truncated)" , fname );
611
585
}
612
- php_stream_close (fp );
613
- phar_destroy_phar_data (myphar );
614
- return FAILURE ;
586
+ goto bail ;
615
587
}
616
588
}
617
589
@@ -623,12 +595,10 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
623
595
624
596
/* ensure signature set */
625
597
if (!myphar -> is_data && PHAR_G (require_hash ) && !myphar -> signature ) {
626
- php_stream_close (fp );
627
- phar_destroy_phar_data (myphar );
628
598
if (error ) {
629
599
spprintf (error , 0 , "tar-based phar \"%s\" does not have a signature" , fname );
630
600
}
631
- return FAILURE ;
601
+ goto bail ;
632
602
}
633
603
634
604
myphar -> fname = pestrndup (fname , fname_len , myphar -> is_persistent );
@@ -655,9 +625,7 @@ zend_result phar_parse_tarfile(php_stream* fp, char *fname, size_t fname_len, ch
655
625
if (error ) {
656
626
spprintf (error , 4096 , "phar error: Unable to add tar-based phar \"%s\" to phar registry" , fname );
657
627
}
658
- php_stream_close (fp );
659
- phar_destroy_phar_data (myphar );
660
- return FAILURE ;
628
+ goto bail ;
661
629
}
662
630
663
631
myphar = actual ;
0 commit comments