Package init

This commit is contained in:
overweight 2019-09-30 10:53:25 -04:00
commit d98dee1f27
7 changed files with 267 additions and 0 deletions

View File

@ -0,0 +1,37 @@
From 9b320138755542b927df650da0bd1e61ecaa41d7 Mon Sep 17 00:00:00 2001
Message-Id: <9b320138755542b927df650da0bd1e61ecaa41d7.1378117677.git.npajkovs@redhat.com>
From: Vitezslav Samel <vitezslav@samel.cz>
Date: Thu, 29 Aug 2013 10:11:42 +0200
Subject: [PATCH] BUGFIX: fix "Floating point exception" in
tcplog_flowrate_msg()
commit 0d55bee "tcplog_flowrate_msg(): cleanup and fix") removed
condition, which leads to zero division.
Time diff between current time and ->conn_starttime is 0, because of
rate_print updates happen in less then 1 sec and later on, we try to
divide ->bcount by interval, which is 0, hencs zero division.
Reported-by: Erik K. <ummeegge@ipfire.org>
Signed-off-by: Vitezslav Samel <vitezslav@samel.cz>
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
---
src/tcptable.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/tcptable.c b/src/tcptable.c
index a4133d9..e217b19 100644
--- a/src/tcptable.c
+++ b/src/tcptable.c
@@ -437,6 +437,8 @@ static char *tcplog_flowrate_msg(struct tcptableent *entry, char *buf,
size_t bufsize)
{
time_t interval = time(NULL) - entry->conn_starttime;
+ if (interval < 1)
+ interval = 1;
char rbuf[64];
rate_print(entry->bcount / interval, rbuf, sizeof(rbuf));
--
1.8.1.2

View File

@ -0,0 +1,79 @@
From 202b2e7b27a159d54a525b0cfd366b8d52d5a3a1 Mon Sep 17 00:00:00 2001
Message-Id: <202b2e7b27a159d54a525b0cfd366b8d52d5a3a1.1386069831.git.npajkovs@redhat.com>
From: Nikola Pajkovsky <npajkovs@redhat.com>
Date: Tue, 3 Dec 2013 12:12:16 +0100
Subject: [PATCH] Makefile: add -Werror=format-security
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
-Wformat-security
If -Wformat is specified, also warn about uses of format
functions that represent possible security problems. At
present, this warns about calls to printf and scanf functions
where the format string is not a string literal and there are
no format arguments, as in printf (foo);. This may be a
security hole if the format string came from untrusted input
and contains %n. (This is currently a subset of what
-Wformat-nonliteral warns about, but in future warnings may be
added to -Wformat-security that are not included in
-Wformat-nonliteral.)
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
---
Makefile | 2 +-
src/ipfilter.c | 2 +-
src/othptab.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 46e5632e3287..958b0fbeec0f 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ VERSION-FILE: FORCE
@$(SHELL_PATH) ./GEN-VERSION-FILE
-include VERSION-FILE
-CFLAGS = -g -O2 -Wall -W -std=gnu99
+CFLAGS = -g -O2 -Wall -W -std=gnu99 -Werror=format-security
LDFLAGS =
ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
ALL_LDFLAGS = $(LDFLAGS)
diff --git a/src/ipfilter.c b/src/ipfilter.c
index eb17ec7c7615..8c76e4c801c2 100644
--- a/src/ipfilter.c
+++ b/src/ipfilter.c
@@ -146,7 +146,7 @@ void gethostparams(struct hostparams *data, char *init_saddr, char *init_smask,
snprintf(msgstr, 60,
"Invalid protocol input at or near token \"%s\"",
bptr);
- tui_error(ANYKEY_MSG, msgstr);
+ tui_error(ANYKEY_MSG, "%s", msgstr);
doagain = 1;
} else
doagain = 0;
diff --git a/src/othptab.c b/src/othptab.c
index 5c09241fca99..e23f39e5df45 100644
--- a/src/othptab.c
+++ b/src/othptab.c
@@ -407,7 +407,7 @@ void printothpentry(struct othptable *table, struct othptabent *entry,
break;
}
- sprintf(scratchpad, rarp_mac_addr);
+ sprintf(scratchpad, "%s", rarp_mac_addr);
strcat(msgstring, scratchpad);
wattrset(table->othpwin, ARPATTR);
break;
@@ -482,7 +482,7 @@ void printothpentry(struct othptable *table, struct othptabent *entry,
wattrset(table->othpwin, UNKNIPATTR);
protptr = getprotobynumber(entry->protocol);
if (protptr != NULL) {
- sprintf(protname, protptr->p_aliases[0]);
+ sprintf(protname, "%s", protptr->p_aliases[0]);
} else {
sprintf(protname, "IP protocol");
unknown = 1;
--
1.8.3.2

View File

@ -0,0 +1,63 @@
From 690663d07f29789c1ba2260e59c4f71b8721dea6 Mon Sep 17 00:00:00 2001
From: Vitezslav Samel <vitezslav@samel.cz>
Date: Thu, 17 Apr 2014 14:24:23 +0200
Subject: [PATCH 001/111] bugfix: positionptr(): properly allocate newly
created interfaces
When creating new entry in interface list (for interface created when
ifstats() already running) we must allocate/init the rate too.
Fix this bug by creating new function alloc_iflist_entry() and use it
where appropriate.
Signed-off-by: Vitezslav Samel <vitezslav@samel.cz>
Signed-off-by: Nikola Pajkovsky <n.pajkovsky@gmail.com>
---
src/ifstats.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/ifstats.c b/src/ifstats.c
index 2eb51b6..2a5bba4 100644
--- a/src/ifstats.c
+++ b/src/ifstats.c
@@ -126,6 +126,15 @@ static int ifinlist(struct iflist *list, char *ifname)
return result;
}
+static struct iflist *alloc_iflist_entry(void)
+{
+ struct iflist *tmp = xmallocz(sizeof(struct iflist));
+
+ rate_alloc(&tmp->rate, 5);
+
+ return tmp;
+}
+
/*
* Initialize the list of interfaces. This linked list is used in the
* selection boxes as well as in the general interface statistics screen.
@@ -171,10 +180,9 @@ static void initiflist(struct iflist **list)
* At this point, the interface is now sure to be up and running.
*/
- struct iflist *itmp = xmallocz(sizeof(struct iflist));
- strcpy(itmp->ifname, ifname);
+ struct iflist *itmp = alloc_iflist_entry();
itmp->ifindex = ifindex;
- rate_alloc(&itmp->rate, 5);
+ strcpy(itmp->ifname, ifname);
/* make the linked list sorted by ifindex */
struct iflist *cur = *list, *last = NULL;
@@ -211,7 +219,7 @@ static struct iflist *positionptr(struct iflist *iflist, const int ifindex)
}
/* no interface was found, try to create new one */
if (ptmp == NULL) {
- struct iflist *itmp = xmallocz(sizeof(struct iflist));
+ struct iflist *itmp = alloc_iflist_entry();
itmp->ifindex = ifindex;
itmp->index = last->index + 1;
int r = dev_get_ifname(ifindex, itmp->ifname);
--
2.5.5

9
iptraf-ng-logrotate.conf Normal file
View File

@ -0,0 +1,9 @@
# Logrotate file for iptraf
/var/log/iptraf-ng/*.log {
compress
delaycompress
missingok
notifempty
rotate 4
create 0600 root root
}

1
iptraf-ng-tmpfiles.conf Normal file
View File

@ -0,0 +1 @@
d /run/iptraf-ng 0755 root root -

78
iptraf-ng.spec Normal file
View File

@ -0,0 +1,78 @@
Name: iptraf-ng
Summary: A console-based network monitoring utility
Version: 1.1.4
Release: 21
License: GPLv2+
URL: https://github.com/%{name}/%{name}/
Source0: https://github.com/%{name}/%{name}/archive/v%{version}.tar.gz
Source1: %{name}-logrotate.conf
Source2: %{name}-tmpfiles.conf
Patch0: 0001-BUGFIX-fix-Floating-point-exception-in-tcplog_flowra.patch
Patch1: 0002-Makefile-add-Werror-format-security.patch
Patch2: 0003-fix-segfault-in-adding-interface.patch
BuildRequires: gcc ncurses-devel
Obsoletes: iptraf < 3.1
Provides: iptraf = 3.1
%description
IPTraf is a console-based network monitoring program for Linux that
displays information about IP traffic. It returns such information as:
* Current TCP connections
* UDP, ICMP, OSPF, and other types of IP packets
* Packet and byte counts on TCP connections
* IP, TCP, UDP, ICMP, non-IP, and other packet and byte counts
* TCP/UDP counts by ports
* Packet counts by packet sizes
* Packet and byte counts by IP address
* Interface activity
* Flag statuses on TCP packets
* LAN station statistics
If the iptraf command is issued without any command-line options,
the program comes up in interactive mode, with the various facilities
accessed through the main menu.
%package_help
%prep
%autosetup -n %{name}-%{version} -p1
%build
CFLAGS="-g -O2 -Wall -W -std=gnu99 -Werror=format-security %{optflags}" \
LDFLAGS="$RPM_LD_FLAGS"
%make_build V=1
%install
%make_install prefix=%{_prefix}
# Delete files that are not in HTML or PNG format in Documentation.
find Documentation -type f ! -name "*.html" \
-type f ! -name "*.png" \
-type f ! -name "." \
| xargs rm -f
install -D -m 0644 -p %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
install -D -m 0644 %{SOURCE2} %{buildroot}%{_prefix}/lib/tmpfiles.d/%{name}.conf
install -d -m 0755 %{buildroot}%{_localstatedir}/{log,lib}/%{name}
install -d -m 0755 %{buildroot}/run/%{name}/
%files
%defattr(-,root,root)
%license LICENSE
%{_prefix}/lib/tmpfiles.d/%{name}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%{_sbindir}/*ng
%{_localstatedir}/{log,lib}/%{name}
%dir /run/%{name}/
%files help
%defattr(-,root,root)
%doc Documentation FAQ CHANGES README* RELEASE-NOTES
%{_mandir}/man8/*.8.gz
%changelog
* Fri Aug 30 2019 openEuler Buildteam <buildteam@openeuler.org> - 1.1.4-21
- Package init

BIN
v1.1.4.tar.gz Normal file

Binary file not shown.