From 0e3a80f2a4f301ed66893c7297e3d57ad75e6dc0 Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Sun, 27 Nov 2016 13:48:40 +0200 Subject: [PATCH 2/3] Check that a base64 decoded string is long enough to be a UUID This fixes test failures on platforms where Perl pointers stringify to a suitably long string, making "Blah=HASH(0x555555f30d18)" a candidate for base64 decoding. Bug-Debian: https://bugs.debian.org/814929 Bug: https://rt.cpan.org/Ticket/Display.html?id=119111 --- LibUUID.xs | 6 +++++- t/basic.t | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/LibUUID.xs b/LibUUID.xs index 00b4e4c..34d757d 100644 --- a/LibUUID.xs +++ b/LibUUID.xs @@ -139,7 +139,11 @@ STATIC IV sv_to_uuid (SV *sv, uuid_t uuid) { call_pv("MIME::Base64::decode_base64", G_SCALAR); SPAGAIN; - pv = SvPV_nolen(TOPs); + pv = SvPV(TOPs, len); + + /* check that the decoded result looks plausible */ + if (len != sizeof(uuid_t)) + return 0; /* fall through */ case sizeof(uuid_t): diff --git a/t/basic.t b/t/basic.t index 067b8b6..0dcbacc 100644 --- a/t/basic.t +++ b/t/basic.t @@ -71,7 +71,6 @@ is( uuid_to_binary(sub { }), undef, "to_binary(sub { })" ); is( uuid_to_binary(42), undef, "to_binary(IV)" ); for (19..21) { - local $::TODO = 'suitably long strings get blindly decoded (Debian #814929)'; is( uuid_to_binary("Blah=" . "x" x $_), undef, "to_binary(string_with_${_}_padding)"); } -- 2.10.2