Subject: | Nagios::Passive::Gearman::_null_padding: wrong padding for 32-byte keys |
Date: | Mon, 10 Mar 2014 11:16:53 +0000 |
To: | "bug-Nagios-Passive [...] rt.cpan.org" <bug-Nagios-Passive [...] rt.cpan.org> |
From: | Mayer Frank <F.Mayer [...] ssi-schaefer-peem.com> |
Hi,
First off: thank you very much for writing and maintaining this module: it's been a great help to me recently!
Now as to the bug:
My program kept crashing with a message telling me that the key was not 16, 24 or 32 bytes long, even though it was exactly 32 bytes.
While stepping through, I found:
If the encryption key given is 32 bytes, the padding code will produce a key padded to 64 bytes instead of leaving the key as is.
A quick fix for this would be taking the modulo operation after the subtraction instead of before (as in the patch below).
--- Gearman.pm.org
+++ Gearman.pm
@@ -83,7 +83,7 @@
$b=~ s/\0*$//s;
return $b;
}
- return $b . pack("C*", (0) x ($bs - length($b) % $bs));
+ return $b . pack("C*", (0) x (($bs - length($b)) % $bs));
}
1;
Best regards,
Frank Mayer | Customer Service & Support - System Monitoring
SSI SCHÄFER | SSI Schäfer Peem GmbH | Fischeraustraße 27 | 8051 Graz | Austria
Phone +43 316 6096-498 | Fax +43 316 6096-409,456
F.Mayer@ssi-schaefer-peem.com
Website | Blog | YouTube | Facebook
SSI Schäfer Peem GmbH | 8051 Graz | Austria
Regional Court Graz | Commercial Register 179677 g | VAT no. ATU 52446606
Managing Directors: Rudolf Keller, Rainer Buchmann