Subject: | new_uuid() returns uninitialized memory for version 1 |
Running t/basic.t under valgrind shows uses of uninitialized values, as seen below. This seems to be due to a typo in new_uuid(): there's a 'ggdefault' label, which should presumably be the 'default' case for switch.
Proposed patch attached.
1..50
ok 1 - use Data::UUID::LibUUID;
ok 2 - new_uuid_string
==24842== Use of uninitialised value of size 8
==24842== at 0x55A0121: _itoa_word (_itoa.c:180)
==24842== by 0x55A4889: vfprintf (vfprintf.c:1636)
==24842== by 0x565286B: __vsprintf_chk (vsprintf_chk.c:83)
==24842== by 0x56527BC: __sprintf_chk (sprintf_chk.c:31)
==24842== by 0x775E722: sprintf (stdio2.h:33)
==24842== by 0x775E722: uuid_unparse_x (unparse.c:56)
==24842== by 0x7559874: XS_Data__UUID__LibUUID_new_uuid_string (LibUUID.xs:223)
==24842== by 0x1DC0AF: Perl_pp_entersub (pp_hot.c:3987)
==24842== by 0x1D45D5: Perl_runops_standard (run.c:41)
==24842== by 0x15A6E8: S_run_body (perl.c:2488)
==24842== by 0x15A6E8: perl_run (perl.c:2411)
==24842== by 0x13385C: main (perlmain.c:116)
==24842==
==24842== Conditional jump or move depends on uninitialised value(s)
==24842== at 0x55A0128: _itoa_word (_itoa.c:180)
==24842== by 0x55A4889: vfprintf (vfprintf.c:1636)
==24842== by 0x565286B: __vsprintf_chk (vsprintf_chk.c:83)
==24842== by 0x56527BC: __sprintf_chk (sprintf_chk.c:31)
==24842== by 0x775E722: sprintf (stdio2.h:33)
==24842== by 0x775E722: uuid_unparse_x (unparse.c:56)
==24842== by 0x7559874: XS_Data__UUID__LibUUID_new_uuid_string (LibUUID.xs:223)
==24842== by 0x1DC0AF: Perl_pp_entersub (pp_hot.c:3987)
==24842== by 0x1D45D5: Perl_runops_standard (run.c:41)
==24842== by 0x15A6E8: S_run_body (perl.c:2488)
==24842== by 0x15A6E8: perl_run (perl.c:2411)
==24842== by 0x13385C: main (perlmain.c:116)
==24842==
==24842== Conditional jump or move depends on uninitialised value(s)
==24842== at 0x55A4991: vfprintf (vfprintf.c:1636)
==24842== by 0x565286B: __vsprintf_chk (vsprintf_chk.c:83)
==24842== by 0x56527BC: __sprintf_chk (sprintf_chk.c:31)
==24842== by 0x775E722: sprintf (stdio2.h:33)
==24842== by 0x775E722: uuid_unparse_x (unparse.c:56)
==24842== by 0x7559874: XS_Data__UUID__LibUUID_new_uuid_string (LibUUID.xs:223)
==24842== by 0x1DC0AF: Perl_pp_entersub (pp_hot.c:3987)
==24842== by 0x1D45D5: Perl_runops_standard (run.c:41)
==24842== by 0x15A6E8: S_run_body (perl.c:2488)
==24842== by 0x15A6E8: perl_run (perl.c:2411)
==24842== by 0x13385C: main (perlmain.c:116)
==24842==
==24842== Conditional jump or move depends on uninitialised value(s)
==24842== at 0x55A3851: vfprintf (vfprintf.c:1636)
==24842== by 0x565286B: __vsprintf_chk (vsprintf_chk.c:83)
==24842== by 0x56527BC: __sprintf_chk (sprintf_chk.c:31)
==24842== by 0x775E722: sprintf (stdio2.h:33)
==24842== by 0x775E722: uuid_unparse_x (unparse.c:56)
==24842== by 0x7559874: XS_Data__UUID__LibUUID_new_uuid_string (LibUUID.xs:223)
==24842== by 0x1DC0AF: Perl_pp_entersub (pp_hot.c:3987)
==24842== by 0x1D45D5: Perl_runops_standard (run.c:41)
==24842== by 0x15A6E8: S_run_body (perl.c:2488)
==24842== by 0x15A6E8: perl_run (perl.c:2411)
==24842== by 0x13385C: main (perlmain.c:116)
==24842==
==24842== Conditional jump or move depends on uninitialised value(s)
==24842== at 0x55A38D2: vfprintf (vfprintf.c:1636)
==24842== by 0x565286B: __vsprintf_chk (vsprintf_chk.c:83)
==24842== by 0x56527BC: __sprintf_chk (sprintf_chk.c:31)
==24842== by 0x775E722: sprintf (stdio2.h:33)
==24842== by 0x775E722: uuid_unparse_x (unparse.c:56)
==24842== by 0x7559874: XS_Data__UUID__LibUUID_new_uuid_string (LibUUID.xs:223)
==24842== by 0x1DC0AF: Perl_pp_entersub (pp_hot.c:3987)
==24842== by 0x1D45D5: Perl_runops_standard (run.c:41)
==24842== by 0x15A6E8: S_run_body (perl.c:2488)
==24842== by 0x15A6E8: perl_run (perl.c:2411)
==24842== by 0x13385C: main (perlmain.c:116)
==24842==
ok 3 - new_uuid_string(1)
Subject: | 0001-Fix-use-of-uninitialized-memory-in-new_uuid-when-ver.patch |
From 8cc15c21ebd8755ae7d15f178dd14999d9552fda Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Tue, 6 Dec 2016 23:20:55 +0200
Subject: [PATCH] Fix use of uninitialized memory in new_uuid() when version==1
This was discovered by running the test under valgrind.
---
LibUUID.xs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/LibUUID.xs b/LibUUID.xs
index 34d757d..1a3393c 100644
--- a/LibUUID.xs
+++ b/LibUUID.xs
@@ -74,7 +74,7 @@ STATIC void new_uuid (IV version, uuid_t uuid) {
case UUID_TYPE_RANDOM:
uuid_generate_random(uuid);
break;
- ggdefault:
+ default:
uuid_generate(uuid);
}
}
--
2.10.2