Subject: | unicode key bug |
POD says: "$key may also be specified as a four character string, in
which case it will be converted to an integer value automatically"
but the pack/unpack you used for Str->Int conversion will fail if this
key contains unicode (multibyte) characters. especially dangerous in
situation, where unpack results with the same ID for different four
character keys:
--------8><--------
#!/usr/bin/perl
use utf8;
use strict;
use warnings;
use IPC::ShareLite;
my $share1 = IPC::ShareLite->new(
'-key' => "AAAĄ", # in hex it's 41 41 41 c4 84
'-create' => 'yes',
'-destroy' => 'no',
) or die $!;
my $share2 = IPC::ShareLite->new(
'-key' => "AAAĘ", # in hex it's 41 41 41 c4 98
'-create' => 'yes',
'-destroy' => 'no',
) or die $!;
$share1->store('Hello world');
print $share2->fetch(); # shouldn't be printed !!
--------8><--------
IMO range checking should be enforced to accept single byte characters,
or "use bytes; bytes:length($key);" validation, along with POD update.
thanks for this module!