Skip Menu |

This queue is for tickets about the Socket-Netlink CPAN distribution.

Report information
The Basics
Id: 118688
Status: open
Priority: 0/
Queue: Socket-Netlink

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.04
Fixed in: (no value)



Subject: Wrong nlmsgerr length check
My compiler reports these warnings: Building Socket-Netlink test-3075-0.c: In function 'main': test-3075-0.c:5:7: warning: unused variable 'ctrl' [-Wunused-variable] int ctrl = CTRL_CMD_NEWMCAST_GRP; ^~~~ gcc -I/usr/lib64/perl5/CORE -DVERSION="0.04" -DXS_VERSION="0.04" -fPIC -c -D_REENTRANT -D_GNU_SOURCE -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -o lib/Socket/Netlink.o lib/Socket/Netlink.c lib/Socket/Netlink.xs: In function 'XS_Socket__Netlink_unpack_nlmsgerr': lib/Socket/Netlink.xs:195:20: warning: comparison of constant '20ul' with boolean expression is always false [-Wbool-compare] if(!SvCUR(msg) == sizeof(nlmsgerr)) ^~ lib/Socket/Netlink.xs:195:20: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] ExtUtils::Mkbootstrap::Mkbootstrap('blib/arch/auto/Socket/Netlink/Netlink.bs') gcc -shared -Wl,-z,relro -L/usr/local/lib -fstack-protector-strong -lperl -o blib/arch/auto/Socket/Netlink/Netlink.so lib/Socket/Netlink.o Especially the lib/Socket/Netlink.xs:195 is troublesome. The code is: if(!SvPOK(msg)) croak("Expected a string message"); → if(!SvCUR(msg) == sizeof(nlmsgerr)) croak("Expected %d bytes of message", sizeof(nlmsgerr)); I think the string length comparison is wrong. Correct one should be: if(SvCUR(msg) != sizeof(nlmsgerr))
From: ppisar [...] redhat.com
Dne St 09.lis.2016 04:39:10, ppisar napsal(a): Show quoted text
> I think the string length comparison is wrong.
Attach patch fixes it.
Subject: 0001-Fix-nlmsgerr-length-check.patch
From 01a86755a7d1ac97b1218ffe43ae8d1a8fdc4aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Wed, 9 Nov 2016 10:42:23 +0100 Subject: [PATCH] Fix nlmsgerr length check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a wrong boolean expression reported by a GCC warning: lib/Socket/Netlink.xs: In function 'XS_Socket__Netlink_unpack_nlmsgerr': lib/Socket/Netlink.xs:195:20: warning: comparison of constant '20ul' with boolean expression is always false [-Wbool-compare] if(!SvCUR(msg) == sizeof(nlmsgerr)) ^~ lib/Socket/Netlink.xs:195:20: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] This patch fixes it. CPAN RT#118688. Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/Socket/Netlink.xs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Socket/Netlink.xs b/lib/Socket/Netlink.xs index 6211b7f..6900819 100644 --- a/lib/Socket/Netlink.xs +++ b/lib/Socket/Netlink.xs @@ -192,7 +192,7 @@ unpack_nlmsgerr(msg) PPCODE: if(!SvPOK(msg)) croak("Expected a string message"); - if(!SvCUR(msg) == sizeof(nlmsgerr)) + if(SvCUR(msg) != sizeof(nlmsgerr)) croak("Expected %d bytes of message", sizeof(nlmsgerr)); Copy(SvPVbyte_nolen(msg), &nlmsgerr, sizeof(nlmsgerr), char); -- 2.7.4
On Wed Nov 09 04:46:40 2016, ppisar wrote: Show quoted text
> Dne St 09.lis.2016 04:39:10, ppisar napsal(a):
> > I think the string length comparison is wrong.
> > Attach patch fixes it.
Ah oops. Yes that looks right. Thanks -- Paul Evans