ver_linux: Process input coming from procmaps that matches libc only
authorAlexander Kapshuk <[email protected]>
Thu, 31 May 2018 19:22:46 +0000 (22:22 +0300)
committerGreg Kroah-Hartman <[email protected]>
Sat, 7 Jul 2018 15:44:52 +0000 (17:44 +0200)
Currently, input coming from /proc/self/maps is split into fields without
checking whether or not it matches libc.so. This is not efficient.
All text processing should only be performed on lines of input that
match libc.so.

Signed-off-by: Alexander Kapshuk <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
scripts/ver_linux

index 7227994ccf63a2a96732399457c0384452672d8a..e1dc041f903f257a00f135e730ed373b47476478 100755 (executable)
@@ -32,11 +32,13 @@ BEGIN {
        printversion("Nfs-utils", version("showmount --version"))
 
        while (getline <"/proc/self/maps" > 0) {
-               n = split($0, procmaps, "/")
-               if (/libc.*so$/ && match(procmaps[n], /[0-9]+([.]?[0-9]+)+/)) {
-                       ver = substr(procmaps[n], RSTART, RLENGTH)
-                       printversion("Linux C Library", ver)
-                       break
+               if (/libc.*\.so$/) {
+                       n = split($0, procmaps, "/")
+                       if (match(procmaps[n], /[0-9]+([.]?[0-9]+)+/)) {
+                               ver = substr(procmaps[n], RSTART, RLENGTH)
+                               printversion("Linux C Library", ver)
+                               break
+                       }
                }
        }