This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tentative fix for RT#125350 - AFL detected crash.
[perl5.git] / Porting / findrfuncs
old mode 100644 (file)
new mode 100755 (executable)
index bef2759..c9a7ff8
@@ -1,11 +1,14 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl -ws
 
 #
 # findrfuncs: find reentrant variants of functions used in an executable.
+#
 # Requires a functional "nm -u".  Searches headers in /usr/include
 # to find available *_r functions and looks for non-reentrant
 # variants used in the supplied executable.
 #
+# Requires debug info in the shared libraries/executables.
+#
 # Gurusamy Sarathy
 # gsar@ActiveState.com
 #
@@ -65,7 +68,13 @@ delete $rfuncs{setlocale_r} if $^O eq 'linux';
 my $netdb_r_obsolete;
 if ($^O eq 'hpux') {
     delete $rfuncs{crypt_r};
+    delete $rfuncs{drand48_r};
+    delete $rfuncs{endgrent_r};
+    delete $rfuncs{endpwent_r};
+    delete $rfuncs{getgrent_r};
+    delete $rfuncs{getpwent_r};
     delete $rfuncs{setlocale_r};
+    delete $rfuncs{srand48_r};
     delete $rfuncs{strerror_r};
     $netdb_r_obsolete = 1;
 } elsif ($^O eq 'dec_osf') {
@@ -84,8 +93,8 @@ if ($netdb_r_obsolete) {
                      getnetbyaddr_r
                      getnetbyname_r
                      getnetent_r
-                     getprotobynumber_r
                      getprotobyname_r
+                     getprotobynumber_r
                      getprotoent_r
                      getservbyname_r
                      getservbyport_r
@@ -100,12 +109,12 @@ my %syms;
 
 for my $exe (@EXES) {
     # warn "#--- $exe\n";
-    for my $sym (`$NMU $exe`) {
+    for my $sym (`$NMU $exe 2>/dev/null`) {
         chomp $sym;
         $sym =~ s/^\s+//;
         $sym =~ s/^([0-9A-Fa-f]+\s+)?[Uu]\s+//;
         $sym =~ s/\s+[Uu]\s+-$//;
-        next if /\s/;
+        next if $sym =~ /\s/;
         $sym =~ s/\@.*\z//;    # remove @@GLIBC_2.0 etc
         # warn "#### $sym\n";
         if (exists $rfuncs{"${sym}_r"} && ! $syms{"$sym:$exe"}++) {
@@ -122,4 +131,3 @@ for my $exe (@EXES) {
     }
     @syms = ();
 }
-