Skip Menu |

This queue is for tickets about the Nagios-Passive CPAN distribution.

Report information
The Basics
Id: 93700
Status: resolved
Priority: 0/
Queue: Nagios-Passive

People
Owner: DATA [...] cpan.org
Requestors: F.Mayer [...] ssi-schaefer-peem.com
Cc:
AdminCc:

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



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
On Mon Mar 10 07:17:06 2014, F.Mayer@ssi-schaefer-peem.com wrote: Show quoted text
> 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.
Nice catch :) Show quoted text
> 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)); > }
I've used a different padding code for the key. _null_padding is still used for padding the payload. Crypt::CBC does it this way, they have even documented it in this way, they might have a good reason for that. So padding for the payload is unchanged, i'm just padding the key differently: https://github.com/datamuc/Nagios-Passive/commit/08ae02e443696694288fc14ddcf4517c39e3047a Thanks. 0.3.6 including the fix has been uploaded to the CPAN.