]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: fix uninitialized fdisk_labelitem
authorRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 26 Oct 2016 15:04:30 +0000 (17:04 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 27 Oct 2016 08:43:45 +0000 (10:43 +0200)
fdisk -l could crash randomly. Only seen on some i586 systems with
certain exotic compiler options.

The problem was that this item is later used in
function fdisk_reset_labelitem() like this:

    if (li->type == 's')
        free(li->data.str);

This may crash if item is randomly initialized.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
libfdisk/src/label.c

index 5cbbe422e84d62c182a44e80e264ab9d59e25b4c..0e83fdf34bbc04f05735ed5ee25aeed537e48b1e 100644 (file)
@@ -416,7 +416,7 @@ int fdisk_locate_disklabel(struct fdisk_context *cxt, int n, const char **name,
  */
 int fdisk_get_disklabel_id(struct fdisk_context *cxt, char **id)
 {
-       struct fdisk_labelitem item;
+       struct fdisk_labelitem item = {0};
        int rc;
 
        if (!cxt || !cxt->label || !id)