Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Sys-Mmap CPAN distribution.

Report information
The Basics
Id: 22615
Status: resolved
Priority: 0/
Queue: Sys-Mmap

People
Owner: TODDR [...] cpan.org
Requestors: whatever [...] davidnicol.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.13
Fixed in: 0.13_01



Subject: munmap($unseen) segfaults
[david@westport]$ perl -e 'use Sys::Mmap; munmap($unseen) or warn $!' Segmentation fault shouldn't be hard to add a check for this -- I was expecting that it would simply fail.
The XS needs to check that the variable is SvTYPE(var) == SVt_PV before it tries to unmap it. This patch with tests should fix it.
Subject: patch.txt
diff --git a/Mmap.xs b/Mmap.xs index 1c7b04b..c144a52 100644 --- a/Mmap.xs +++ b/Mmap.xs @@ -203,6 +203,11 @@ munmap(var) CODE: ST(0) = &PL_sv_undef; /* XXX refrain from dumping core if this var wasnt previously mmap'd */ + if(SvTYPE(var) != SVt_PV) { + croak("map pointer is not a stringundef"); + return; + } + if (munmap((MMAP_RETTYPE) SvPVX(var) - SvLEN(var), SvCUR(var) + SvLEN(var)) == -1) { croak("munmap failed! errno %d %s\n", errno, strerror(errno)); return; diff --git a/t/munmap_errors.t b/t/munmap_errors.t new file mode 100644 index 0000000..d250255 --- /dev/null +++ b/t/munmap_errors.t @@ -0,0 +1,19 @@ +#!perl + +use strict; +use warnings; +use Test::More tests => 2; + +use Sys::Mmap; + +{ + my $foo; + eval {munmap($foo)}; + like($@, qr/^map pointer is not a string/, "munmap detects undef strings"); +} + +{ + my $foo = ""; + eval {munmap($foo)}; + is($@, "munmap failed! errno 22 Invalid argument\n", "Unmapped strings die"); +}
This has been resolved in 0.13_01