Skip to content

Commit 712a2c9

Browse files
authored
Merge pull request #2530 from SimonFair/fix(INET)-fix-ip-v6-DNS-issue
fix(INET): fix ip v6 dns issue with ending ::
2 parents c678e48 + c36e966 commit 712a2c9

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

etc/rc.d/rc.inet1.conf

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,27 @@ unzero(){
3434
# function to remove leading zeros in IPv6 address
3535
unzero6(){
3636
local A M Q
37+
if [[ $1 == "::" ]]; then
38+
printf "::"
39+
return 0
40+
fi
41+
# Replace first :: with sentinel
3742
A=${1/::/:-:}
38-
echo -n $(for Q in ${A//:/ }; do [[ $Q != - ]] && printf "$M%x" "0x$Q" || printf ":"; M=:; done)
43+
M=
44+
for Q in ${A//:/ }; do
45+
if [[ $Q != - ]]; then
46+
# Validate hex (1-4 digits)
47+
[[ $Q =~ ^[0-9A-Fa-f]{1,4}$ ]] || return 1
48+
printf "%s%x" "$M" "0x$Q"
49+
else
50+
# Restore a single colon for sentinel
51+
printf ":"
52+
fi
53+
M=:
54+
done
55+
56+
# Handle trailing :: (but avoid adding for the special case "::")
57+
[[ $1 == *:: && $1 != "::" ]] && printf ":"
3958
}
4059

4160
# Bergware - use associative format for multi-dimensional arrays

0 commit comments

Comments
 (0)