Subject: | Spread message unpacking leaves trailing NULs |
The Spread client, when receiving admin messages, unpacks the binary
message as follows:
( $gid1, $gid2, $gid3, $num_memb, $member ) = unpack( "IIIIa*",
$message );
however, when delivered as parameters to _sp_admin, this equates out
to $data->{WHO} having values like:
'#sli1409#count6^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@'
The fix is to replace 'a' with 'Z' in unpack:
( $gid1, $gid2, $gid3, $num_memb, $member ) = unpack( "IIIIZ*",
$message );
Then $data->{WHO} comes back as a "normal" string
(e.g. "#sli1409#count6"), representing its true value and allowing
simple processing of things like:
if ($data->{WHO} eq $priv_name) { ... }
the above test will *always* fail, since it can never be 'eq' without
the trailing NULs.. I've been having to use a regex match to allow for
them, forcing:
if ($data->{WHO} =~ /^$priv_name/) { ... }
Fix attached.
Subject: | member_parsing.diff |
--- SpreadClient.pm~ 2011-02-16 13:26:27.000000000 -0800
+++ SpreadClient.pm 2011-02-16 13:26:40.000000000 -0800
@@ -509,7 +509,7 @@
# Parse the message!
my ( $gid1, $gid2, $gid3, $num_memb, $member );
eval {
- ( $gid1, $gid2, $gid3, $num_memb, $member ) = unpack( "IIIIa*", $message );
+ ( $gid1, $gid2, $gid3, $num_memb, $member ) = unpack( "IIIIZ*", $message );
};
if ( $@ ) {
# Inform our registered listeners