[PATCH 1/4] Use /sbin/ipcalc for IP address validation (#460579)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Modify checkipv4() and checkipv6() in linuxrc.s390 to run /sbin/ipcalc
for address validation.  We were already including the ipcalc program,
we just weren't using it.
---
 loader/linuxrc.s390 |   29 +++--------------------------
 1 files changed, 3 insertions(+), 26 deletions(-)

diff --git a/loader/linuxrc.s390 b/loader/linuxrc.s390
index 1db4167..d9ccca6 100644
--- a/loader/linuxrc.s390
+++ b/loader/linuxrc.s390
@@ -61,42 +61,19 @@ function tv() {
     fi
 }
 
-# for checkipv6 / checkipv4 see also:
-# https://bugzilla.redhat.com/show_bug.cgi?id=234152#c11
-# https://enterprise.redhat.com/issue-tracker/?module=issues&action=view&tid=115847
-
-# see also RFC4291,sec.2.2
-# the following check is incomplete, but sufficient to distinguish from IPv4
 function checkipv6()
 {
     local ip=$1
     [ -z "$ip" ] && return 1
-    echo $ip | awk -F':' '
-        BEGIN {
-          error = 0
-        }
-
-        {
-          if (NF > 8) {
-            error = 1
-            exit error
-          }
-          for (i = 1; i <= NF; i++) {
-            if ( ! match(toupper($i), "^[0-9A-F]{0,4}$") ) {
-              error = 1
-              break
-            }
-          }
-          exit error
-        }
-    '
+    /sbin/ipcalc -c -6 "$ip" >/dev/null 2>&1
     return $?
 }
 
 function checkipv4()
 {
     local ip=$1
-    echo $ip | awk -F'.' '{ if (NF != 4) { exit 1 } i=1; while (i<=NF) { if ($i>255 || $i<0) { exit 1 }; i=i+1; } exit 0 }'
+    [ -z "$ip" ] && return 1
+    /sbin/ipcalc -c -4 "$ip" >/dev/null 2>&1
     return $?
 }
 
-- 
1.6.2.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux