diff --git a/SOURCES/0002-add-support-for-RFC3021.patch b/SOURCES/0002-add-support-for-RFC3021.patch new file mode 100644 index 0000000..2db25b4 --- /dev/null +++ b/SOURCES/0002-add-support-for-RFC3021.patch @@ -0,0 +1,28 @@ +diff --git a/ipcalc.c b/ipcalc.c +index f2bc47a..04c9372 100644 +--- a/ipcalc.c ++++ b/ipcalc.c +@@ -146,7 +146,12 @@ static struct in_addr calc_broadcast(struct in_addr addr, int prefix) + mask.s_addr = prefix2mask(prefix); + + memset(&broadcast, 0, sizeof(broadcast)); +- broadcast.s_addr = (addr.s_addr & mask.s_addr) | ~mask.s_addr; ++ ++ /* if prefix is set to 31 return 255.255.255.255 (RFC3021) */ ++ if (mask.s_addr == htonl(0xFFFFFFFE)) ++ broadcast.s_addr = htonl(0xFFFFFFFF); ++ else ++ broadcast.s_addr = (addr.s_addr & mask.s_addr) | ~mask.s_addr; + return broadcast; + } + +diff --git a/tests/192.168.1.5-31 b/tests/192.168.1.5-31 +index fee8227..b720b56 100644 +--- a/tests/192.168.1.5-31 ++++ b/tests/192.168.1.5-31 +@@ -1,4 +1,4 @@ + NETMASK=255.255.255.254 + PREFIX=31 +-BROADCAST=192.168.1.5 ++BROADCAST=255.255.255.255 + NETWORK=192.168.1.4 diff --git a/SPECS/ipcalc.spec b/SPECS/ipcalc.spec index 4213d72..f5d12c0 100644 --- a/SPECS/ipcalc.spec +++ b/SPECS/ipcalc.spec @@ -1,6 +1,6 @@ Name: ipcalc Version: 0.2.4 -Release: 3%{?dist} +Release: 4%{?dist} Summary: IP network address calculator # This is an updated version of ipcalc originally found @@ -20,6 +20,7 @@ Conflicts: initscripts < 9.63 Obsoletes: ipcalculator < 0.41-20 Patch1: 0001-fix-segfault-in-env-without-libmaxmind.so.patch +Patch2: 0002-add-support-for-RFC3021.patch %description ipcalc provides a simple way to calculate IP information for a host @@ -52,6 +53,9 @@ make check %{_mandir}/man1/ipcalc.1* %changelog +* Thu Oct 10 2019 Martin Osvald - 0.2.4-4 +- Add support for RFC3021 (#1638834) + * Fri Aug 03 2018 Martin Sehnoutka - 0.2.4-3 - Fix segfault in the container environment