[nc] Check accept() return value (#710482)

Petr Sabata psabata at fedoraproject.org
Fri Jun 3 14:51:00 UTC 2011


commit ec43c48fed33c9a44a51c31359ed6164b6b74659
Author: Petr Sabata <contyk at redhat.com>
Date:   Fri Jun 3 16:49:08 2011 +0200

    Check accept() return value (#710482)

 nc-1.100-check-accept.patch |   13 +++++++++++++
 nc.spec                     |    7 ++++++-
 2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/nc-1.100-check-accept.patch b/nc-1.100-check-accept.patch
new file mode 100644
index 0000000..e3a8698
--- /dev/null
+++ b/nc-1.100-check-accept.patch
@@ -0,0 +1,13 @@
+diff --git a/netcat.c b/netcat.c
+index ad57e4e..81cdea8 100644
+--- a/netcat.c
++++ b/netcat.c
+@@ -356,6 +356,8 @@ main(int argc, char *argv[])
+ 				len = sizeof(cliaddr);
+ 				connfd = accept(s, (struct sockaddr *)&cliaddr,
+ 				    &len);
++				if (connfd == -1)
++					errx(1, "accept failed: %s", strerror(errno));
+ 				readwrite(connfd);
+ 				close(connfd);
+ 			}
diff --git a/nc.spec b/nc.spec
index 2174a53..b2f1680 100644
--- a/nc.spec
+++ b/nc.spec
@@ -1,7 +1,7 @@
 Summary:    Reads and writes data across network connections using TCP or UDP
 Name:       nc
 Version:    1.100
-Release:    3%{?dist}
+Release:    4%{?dist}
 URL:        http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/
 License:    BSD ISC
 Group:      Applications/Internet
@@ -17,6 +17,7 @@ Patch5:     nc-1.100-comma.patch
 Patch6:     nc-1.100-libbsd.patch
 Patch7:     nc-1.100-format-size_t.patch
 Patch8:     nc-1.100-initialize-range.patch
+Patch9:     nc-1.100-check-accept.patch
 
 BuildRequires: libbsd-devel
 
@@ -44,6 +45,7 @@ capabilities.
 %patch6 -p1 -b .libbsd
 %patch7 -p1 -b .format-size_t
 %patch8 -p1 -b .initialize-range
+%patch9 -p1 -b .check-accept
 cp -p %{SOURCE1} .
 
 %build
@@ -60,6 +62,9 @@ install -m 644 nc.1 %{buildroot}%{_mandir}/man1
 %{_mandir}/man1/nc.1*
 
 %changelog
+* Fri Jun 03 2011 Petr Sabata <contyk at redhat.com> - 1.100-4
+- Check return value of accept() (#710482)
+
 * Fri Jun 03 2011 Petr Sabata <contyk at redhat.com> - 1.100-3
 - Initialize range (#710464)
 - Remove defattr macro


More information about the scm-commits mailing list