553d6a
From bb147e4f4008b5debde0f87282967a5e52d2d50f Mon Sep 17 00:00:00 2001
553d6a
From: Karel Zak <kzak@redhat.com>
553d6a
Date: Tue, 7 Oct 2014 12:44:34 +0200
553d6a
Subject: [PATCH 181/185] libblkid: zeroize errno on blkid_probe_get_buffer()
553d6a
 success
553d6a
553d6a
Since 37f4060225df0591ab8e1dd676dbc8115d900d4f prober functions are
553d6a
sensitive to errno, it seems more robust to set errno=0 with in
553d6a
blkid_probe_get_buffer() on success than set the zero on all places
553d6a
where we call blkid_probe_get_buffer().
553d6a
553d6a
Addresses: https://github.com/karelzak/util-linux/issues/119
553d6a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1632944
553d6a
Upstream: http://github.com/karelzak/util-linux/commit/00749bc366fe6106df918660a92a388cfff4f35f
553d6a
Signed-off-by: Karel Zak <kzak@redhat.com>
553d6a
---
553d6a
 libblkid/src/probe.c | 5 ++++-
553d6a
 1 file changed, 4 insertions(+), 1 deletion(-)
553d6a
553d6a
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
553d6a
index 07b08441f..ef0a72299 100644
553d6a
--- a/libblkid/src/probe.c
553d6a
+++ b/libblkid/src/probe.c
553d6a
@@ -529,8 +529,10 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
553d6a
 	struct list_head *p;
553d6a
 	struct blkid_bufinfo *bf = NULL;
553d6a
 
553d6a
-	if (pr->size <= 0)
553d6a
+	if (pr->size <= 0) {
553d6a
+		errno = EINVAL;
553d6a
 		return NULL;
553d6a
+	}
553d6a
 
553d6a
 	if (pr->parent &&
553d6a
 	    pr->parent->devno == pr->devno &&
553d6a
@@ -598,6 +600,7 @@ unsigned char *blkid_probe_get_buffer(blkid_probe pr,
553d6a
 		list_add_tail(&bf->bufs, &pr->buffers);
553d6a
 	}
553d6a
 
553d6a
+	errno = 0;
553d6a
 	return off ? bf->data + (off - bf->off) : bf->data;
553d6a
 }
553d6a
 
553d6a
-- 
553d6a
2.20.1
553d6a