]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: zeroize errno on blkid_probe_get_buffer() success
authorKarel Zak <kzak@redhat.com>
Tue, 7 Oct 2014 10:44:34 +0000 (12:44 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 7 Oct 2014 10:44:34 +0000 (12:44 +0200)
Since 37f4060225df0591ab8e1dd676dbc8115d900d4f prober functions are
sensitive to errno, it seems more robust to set errno=0 with in
blkid_probe_get_buffer() on success than set the zero on all places
where we call blkid_probe_get_buffer().

Addresses: https://github.com/karelzak/util-linux/issues/119
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/probe.c

index 4fea3ccb4ac720c854dc684370a01368a8392aa0..3f7e43bec6e9bb52d0ee8912cd3ccea33ec34f6f 100644 (file)
@@ -539,8 +539,10 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
        struct list_head *p;
        struct blkid_bufinfo *bf = NULL;
 
-       if (pr->size <= 0)
+       if (pr->size <= 0) {
+               errno = EINVAL;
                return NULL;
+       }
 
        if (pr->parent &&
            pr->parent->devno == pr->devno &&
@@ -602,6 +604,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
                list_add_tail(&bf->bufs, &pr->buffers);
        }
 
+       errno = 0;
        return off ? bf->data + (off - bf->off) : bf->data;
 }