From 843970b9451d362fd18381ffacb0f029f6208f70 Mon Sep 17 00:00:00 2001 From: lvgenggeng Date: Wed, 27 Dec 2023 14:37:07 +0800 Subject: [PATCH] backport: fix possible overflows Signed-off-by: lvgenggeng (cherry picked from commit 63e91864340cccb5fbb78f1efa2b0a9db56c9544) --- backport-Fix-possible-overflows.patch | 37 +++++++++++++++++++++++++++ libnet.spec | 6 ++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-possible-overflows.patch diff --git a/backport-Fix-possible-overflows.patch b/backport-Fix-possible-overflows.patch new file mode 100644 index 0000000..7e5c81d --- /dev/null +++ b/backport-Fix-possible-overflows.patch @@ -0,0 +1,37 @@ +From 425162fb7a9577f212d44c1b6f6e2ccc36acf131 Mon Sep 17 00:00:00 2001 +From: Thomas Habets +Date: Fri, 1 Nov 2019 17:08:08 +0000 +Subject: [PATCH 1/1] Fix possible overflows + +--- + src/libnet_port_list.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/libnet_port_list.c b/src/libnet_port_list.c +index fff151e..942a856 100644 +--- a/src/libnet_port_list.c ++++ b/src/libnet_port_list.c +@@ -250,16 +250,17 @@ libnet_plist_chain_dump_string(libnet_plist_t *plist) + { + if (plist->bport == plist->eport) + { +- i = snprintf(&buf[j], BUFSIZ, "%d", plist->bport); ++ i = snprintf(&buf[j], BUFSIZ-j, "%d", plist->bport); + } + else + { +- i = snprintf(&buf[j], BUFSIZ, "%d-%d", plist->bport, plist->eport); ++ i = snprintf(&buf[j], BUFSIZ-j, "%d-%d", plist->bport, plist->eport); + } + j += i; + if (plist->next) + { +- snprintf(&buf[j++], BUFSIZ, ","); ++ snprintf(&buf[j], BUFSIZ-j, ","); ++ j++; + } + } + return (strdup(buf)); /* XXX - reentrancy == no */ +-- +2.20.1 + diff --git a/libnet.spec b/libnet.spec index a811a4a..9b5637a 100644 --- a/libnet.spec +++ b/libnet.spec @@ -1,10 +1,11 @@ Name: libnet Version: 1.2 -Release: 1 +Release: 2 Summary: A C library to help with construction and handling of network packets License: BSD URL: https://github.com/libnet/libnet/ Source: https://github.com/libnet/libnet/releases/download/v%{version}/%{name}-%{version}.tar.gz +Patch0: backport-Fix-possible-overflows.patch BuildRequires: automake autoconf libtool %description @@ -70,6 +71,9 @@ rm -f doc/html/Makefile* %doc %{_docdir}/* %changelog +* Wed Dec 27 2023 lvgenggeng - 1.2-2 +- backport: fix possible overflows + * Wed Aug 19 2020 yuboyun - 1.2-1 - Update to version 1.2 -- Gitee