@@ -551,193 +551,26 @@ fi
551
551
552
552
echo >> configure.log
553
553
554
- # conduct a series of tests to resolve eight possible cases of using "vs" or "s" printf functions
555
- # (using stdarg or not), with or without "n" (proving size of buffer), and with or without a
556
- # return value. The most secure result is vsnprintf() with a return value. snprintf() with a
557
- # return value is secure as well, but then gzprintf() will be limited to 20 arguments.
554
+ # Check for ANSI C compliant compiler
558
555
cat > $test .c << EOF
559
556
#include <stdio.h>
560
557
#include <stdarg.h>
561
558
#include "zconf.h"
562
559
int main()
563
560
{
564
- #ifndef STDC
565
- choke me
566
- #endif
561
+ #ifdef STDC
567
562
return 0;
563
+ #endif
564
+ return 1;
568
565
}
569
566
EOF
570
567
if try $CC -c $CFLAGS $test .c; then
571
- echo " Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()." | tee -a configure.log
572
-
573
- echo >> configure.log
574
- cat > $test .c << EOF
575
- #include <stdio.h>
576
- #include <stdarg.h>
577
- int mytest(const char *fmt, ...)
578
- {
579
- char buf[20];
580
- va_list ap;
581
- va_start(ap, fmt);
582
- vsnprintf(buf, sizeof(buf), fmt, ap);
583
- va_end(ap);
584
- return 0;
585
- }
586
- int main()
587
- {
588
- return (mytest("Hello%d\n", 1));
589
- }
590
- EOF
591
- if try $CC $CFLAGS -o $test $test .c; then
592
- echo " Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
593
-
594
- echo >> configure.log
595
- cat > $test .c << EOF
596
- #include <stdio.h>
597
- #include <stdarg.h>
598
- int mytest(const char *fmt, ...)
599
- {
600
- int n;
601
- char buf[20];
602
- va_list ap;
603
- va_start(ap, fmt);
604
- n = vsnprintf(buf, sizeof(buf), fmt, ap);
605
- va_end(ap);
606
- return n;
607
- }
608
- int main()
609
- {
610
- return (mytest("Hello%d\n", 1));
611
- }
612
- EOF
613
-
614
- if try $CC -c $CFLAGS $test .c; then
615
- echo " Checking for return value of vsnprintf()... Yes." | tee -a configure.log
616
- else
617
- CFLAGS=" $CFLAGS -DHAS_vsnprintf_void"
618
- SFLAGS=" $SFLAGS -DHAS_vsnprintf_void"
619
- echo " Checking for return value of vsnprintf()... No." | tee -a configure.log
620
- echo " WARNING: apparently vsnprintf() does not return a value. zlib" | tee -a configure.log
621
- echo " can build but will be open to possible string-format security" | tee -a configure.log
622
- echo " vulnerabilities." | tee -a configure.log
623
- fi
624
- else
625
- CFLAGS=" $CFLAGS -DNO_vsnprintf"
626
- SFLAGS=" $SFLAGS -DNO_vsnprintf"
627
- echo " Checking for vsnprintf() in stdio.h... No." | tee -a configure.log
628
- echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
629
- echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
630
- echo " vulnerabilities." | tee -a configure.log
631
-
632
- echo >> configure.log
633
- cat > $test .c << EOF
634
- #include <stdio.h>
635
- #include <stdarg.h>
636
- int mytest(const char *fmt, ...)
637
- {
638
- int n;
639
- char buf[20];
640
- va_list ap;
641
- va_start(ap, fmt);
642
- n = vsprintf(buf, fmt, ap);
643
- va_end(ap);
644
- return n;
645
- }
646
- int main()
647
- {
648
- return (mytest("Hello%d\n", 1));
649
- }
650
- EOF
651
-
652
- if try $CC -c $CFLAGS $test .c; then
653
- echo " Checking for return value of vsprintf()... Yes." | tee -a configure.log
654
- else
655
- CFLAGS=" $CFLAGS -DHAS_vsprintf_void"
656
- SFLAGS=" $SFLAGS -DHAS_vsprintf_void"
657
- echo " Checking for return value of vsprintf()... No." | tee -a configure.log
658
- echo " WARNING: apparently vsprintf() does not return a value. zlib" | tee -a configure.log
659
- echo " can build but will be open to possible string-format security" | tee -a configure.log
660
- echo " vulnerabilities." | tee -a configure.log
661
- fi
662
- fi
568
+ echo " Checking for ANSI C compliant compiler... Yes." | tee -a configure.log
569
+ :
663
570
else
664
- echo " Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()." | tee -a configure.log
665
-
666
- echo >> configure.log
667
- cat > $test .c << EOF
668
- #include <stdio.h>
669
- int mytest()
670
- {
671
- char buf[20];
672
- snprintf(buf, sizeof(buf), "%s", "foo");
673
- return 0;
674
- }
675
- int main()
676
- {
677
- return (mytest());
678
- }
679
- EOF
680
-
681
- if try $CC $CFLAGS -o $test $test .c; then
682
- echo " Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
683
-
684
- echo >> configure.log
685
- cat > $test .c << EOF
686
- #include <stdio.h>
687
- int mytest()
688
- {
689
- char buf[20];
690
- return snprintf(buf, sizeof(buf), "%s", "foo");
691
- }
692
- int main()
693
- {
694
- return (mytest());
695
- }
696
- EOF
697
-
698
- if try $CC -c $CFLAGS $test .c; then
699
- echo " Checking for return value of snprintf()... Yes." | tee -a configure.log
700
- else
701
- CFLAGS=" $CFLAGS -DHAS_snprintf_void"
702
- SFLAGS=" $SFLAGS -DHAS_snprintf_void"
703
- echo " Checking for return value of snprintf()... No." | tee -a configure.log
704
- echo " WARNING: apparently snprintf() does not return a value. zlib" | tee -a configure.log
705
- echo " can build but will be open to possible string-format security" | tee -a configure.log
706
- echo " vulnerabilities." | tee -a configure.log
707
- fi
708
- else
709
- CFLAGS=" $CFLAGS -DNO_snprintf"
710
- SFLAGS=" $SFLAGS -DNO_snprintf"
711
- echo " Checking for snprintf() in stdio.h... No." | tee -a configure.log
712
- echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
713
- echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
714
- echo " vulnerabilities." | tee -a configure.log
715
-
716
- echo >> configure.log
717
- cat > $test .c << EOF
718
- #include <stdio.h>
719
- int mytest()
720
- {
721
- char buf[20];
722
- return sprintf(buf, "%s", "foo");
723
- }
724
- int main()
725
- {
726
- return (mytest());
727
- }
728
- EOF
729
-
730
- if try $CC -c $CFLAGS $test .c; then
731
- echo " Checking for return value of sprintf()... Yes." | tee -a configure.log
732
- else
733
- CFLAGS=" $CFLAGS -DHAS_sprintf_void"
734
- SFLAGS=" $SFLAGS -DHAS_sprintf_void"
735
- echo " Checking for return value of sprintf()... No." | tee -a configure.log
736
- echo " WARNING: apparently sprintf() does not return a value. zlib" | tee -a configure.log
737
- echo " can build but will be open to possible string-format security" | tee -a configure.log
738
- echo " vulnerabilities." | tee -a configure.log
739
- fi
740
- fi
571
+ echo " Checking for ANSI C compliant compiler... No." | tee -a configure.log
572
+ echo " Error: ANSI C compatible compiler needed, cannot continue." | tee -a configure.log
573
+ leave 1
741
574
fi
742
575
743
576
# see if we can hide zlib internal symbols that are linked between separate source files
0 commit comments