integ/base/initscripts/centos/patches/sysconfig-unsafe-usage-of-l...

34 lines
1.2 KiB
Diff

From d3d109136f6e01ec1d8291ff89f3e00ff64cab31 Mon Sep 17 00:00:00 2001
From: Allain Legacy <allain.legacy@windriver.com>
Date: Thu, 17 Nov 2016 11:37:38 -0500
Subject: [PATCH] sysconfig: unsafe usage of linkdelay variable
If the LINKDELAY variable is an alphabetic string instead of an integer then
the calculation in check_link_down() causes delay to be set to 0. That causes
the loop to never execute and for the caller to think that the link is always
down.
This does not address but is related to CGTS-5821
Signed-off-by: Allain Legacy <allain.legacy@windriver.com>
---
sysconfig/network-scripts/network-functions | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index affa8ba..a9821f6 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -461,7 +461,7 @@ check_link_down ()
fi
timeout=0
delay=20
- [ -n "$LINKDELAY" ] && delay=$(($LINKDELAY * 2))
+ [[ $LINKDELAY =~ ^[0-9]+$ ]] && delay=$(($LINKDELAY * 2))
while [ $timeout -le $delay ]; do
[ "$(cat /sys/class/net/$REALDEVICE/carrier 2>/dev/null)" == "1" ] && return 1
usleep 500000
--
1.9.1