diff --git a/SOURCES/Socket-2.018-Fix-calling-getnameinfo-on-tainted-value.patch b/SOURCES/Socket-2.018-Fix-calling-getnameinfo-on-tainted-value.patch
new file mode 100644
index 0000000..a5a4789
--- /dev/null
+++ b/SOURCES/Socket-2.018-Fix-calling-getnameinfo-on-tainted-value.patch
@@ -0,0 +1,69 @@
+From 66cdf0a24913a97cfd0909340f2c74b8b60bf56a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
+Date: Mon, 20 Apr 2015 17:38:57 +0200
+Subject: [PATCH] Fix calling getnameinfo() on tainted value
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This is upstream fix for calling getnameinfo() on tained value ported
+to 2.010:
+
+2.018   2015/02/12 13:42:41
+        [BUGFIXES]
+         * Fix for "addr is not a string" test to use SvPOKp() before 5.18
+
+2.017   2015/02/10 12:05:14
+        [BUGFIXES]
+         * Remember to SvGETMAGIC in getnameinfo() (RT79557)
+
+https://rt.cpan.org/Public/Bug/Display.html?id=79557
+https://bugzilla.redhat.com/show_bug.cgi?id=1200167
+http://www.gossamer-threads.com/lists/spamassassin/users/189005#189005
+Signed-off-by: Petr Písař <ppisar@redhat.com>
+
+diff --git a/Socket.xs b/Socket.xs
+index 3cc90f6..753cd09 100644
+--- a/Socket.xs
++++ b/Socket.xs
+@@ -520,6 +520,7 @@ static void xs_getnameinfo(pTHX_ CV *cv)
+ 	SP -= items;
+ 
+ 	addr = ST(0);
++	SvGETMAGIC(addr);
+ 
+ 	if(items < 2)
+ 		flags = 0;
+@@ -534,7 +535,7 @@ static void xs_getnameinfo(pTHX_ CV *cv)
+ 	want_host = !(xflags & NIx_NOHOST);
+ 	want_serv = !(xflags & NIx_NOSERV);
+ 
+-	if(!SvPOK(addr))
++	if(!SvPOKp(addr))
+ 		croak("addr is not a string");
+ 
+ 	addr_len = SvCUR(addr);
+diff --git a/t/getnameinfo.t b/t/getnameinfo.t
+index ca24e2c..23a7669 100644
+--- a/t/getnameinfo.t
++++ b/t/getnameinfo.t
+@@ -1,6 +1,6 @@
+ use strict;
+ use warnings;
+-use Test::More tests => 14;
++use Test::More tests => 15;
+ 
+ use Socket qw(:addrinfo AF_INET pack_sockaddr_in inet_aton);
+ 
+@@ -40,3 +40,8 @@ cmp_ok( $err, "==", 0, '$err == 0 for {family=AF_INET,port=80,sinaddr=127.0.0.1}
+ 
+ is( $host, "127.0.0.1", '$host is 127.0.0.1 for NH' );
+ is( $service, $expect_service, "\$service is $expect_service for NH" );
++
++# RT79557
++pack_sockaddr_in( 80, inet_aton( "127.0.0.1" ) ) =~ m/^(.*)$/s;
++( $err, $host, $service ) = getnameinfo( $1, NI_NUMERICHOST|NI_NUMERICSERV );
++cmp_ok( $err, "==", 0, '$err == 0 for $1' ) or diag( '$err was: ' . $err );
+-- 
+2.1.0
+
diff --git a/SPECS/perl-Socket.spec b/SPECS/perl-Socket.spec
index cf9faab..10eb0a8 100644
--- a/SPECS/perl-Socket.spec
+++ b/SPECS/perl-Socket.spec
@@ -1,12 +1,15 @@
 %global cpan_version 2.010
 Name:           perl-Socket
 Version:        %(echo '%{cpan_version}' | tr '_' '.')
-Release:        3%{?dist}
+Release:        4%{?dist}
 Summary:        Networking constants and support functions
 License:        GPL+ or Artistic
 Group:          Development/Libraries
 URL:            http://search.cpan.org/dist/Socket/
 Source0:        http://search.cpan.org/CPAN/authors/id/P/PE/PEVANS/Socket-%{cpan_version}.tar.gz
+# Fix calling getnameinfo() on tainted value BZ#1200167
+# Backported fixes from 2.017 and 2.018
+Patch0:         Socket-2.018-Fix-calling-getnameinfo-on-tainted-value.patch
 BuildRequires:  perl
 BuildRequires:  perl(Config)
 BuildRequires:  perl(ExtUtils::CBuilder)
@@ -38,6 +41,7 @@ human-readable and native binary forms, and for hostname resolver operations.
 
 %prep
 %setup -q -n Socket-%{cpan_version}
+%patch0 -p1
 
 %build
 perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS"
@@ -59,6 +63,9 @@ make test
 %{_mandir}/man3/*
 
 %changelog
+* Thu Mar 03 2016 Jitka Plesnikova <jplesnik@redhat.com> - 2.010-4
+- Fix calling getnameinfo on tainted value (bug #1200167)
+
 * Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 2.010-3
 - Mass rebuild 2014-01-24