From eba586f053161ff799e273d048f8c203e0ff9181 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Wed, 10 May 2006 16:42:03 +0000 Subject: [PATCH] Fix uuid_from_num() buffer overrun. --- WHATS_NEW | 1 + lib/format1/disk-rep.c | 4 +++- lib/format_text/import.c | 2 +- lib/uuid/uuid.c | 2 -- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 41fbd1c48..7b7e2f268 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.06 - ================================= + Fix uuid_from_num() buffer overrun. Make SIZE_SHORT the default for display_size(). Fix some memory leaks in error paths found by coverity. Use C99 struct initialisers. diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c index 4c0b1a5ea..b7708819e 100644 --- a/lib/format1/disk-rep.c +++ b/lib/format1/disk-rep.c @@ -153,8 +153,10 @@ static int _munge_formats(struct pv_disk *pvd) } /* If UUID is missing, create one */ - if (pvd->pv_uuid[0] == '\0') + if (pvd->pv_uuid[0] == '\0') { uuid_from_num((char *)pvd->pv_uuid, pvd->pv_number); + pvd->pv_uuid[ID_LEN] = '\0'; + } return 1; } diff --git a/lib/format_text/import.c b/lib/format_text/import.c index 472a4cb2d..b5f3d9c02 100644 --- a/lib/format_text/import.c +++ b/lib/format_text/import.c @@ -33,7 +33,7 @@ const char *text_vgname_import(const struct format_type *fmt, { struct config_tree *cft; struct text_vg_version_ops **vsn; - const char *vgname; + const char *vgname = NULL; static int _text_import_initialised = 0; diff --git a/lib/uuid/uuid.c b/lib/uuid/uuid.c index fb60a26c6..df4407f8f 100644 --- a/lib/uuid/uuid.c +++ b/lib/uuid/uuid.c @@ -40,8 +40,6 @@ void uuid_from_num(char *uuid, uint32_t num) uuid[i - 1] = _c[num % (sizeof(_c) - 1)]; num /= sizeof(_c) - 1; } - - uuid[ID_LEN] = '\0'; } int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num)