summaryrefslogtreecommitdiffstats
path: root/shlibs/blkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2009-11-10 14:00:13 +0100
committerKarel Zak2009-11-10 14:00:13 +0100
commitcdd5badafd0be42f999ca1e0d69225fff2190472 (patch)
treee18beca3ce5b5965013631a71cadad3975086ef8 /shlibs/blkid/src/probe.c
parentRevert "libblkid: fix buffer usage in FAT prober" (diff)
downloadkernel-qcow2-util-linux-cdd5badafd0be42f999ca1e0d69225fff2190472.tar.gz
kernel-qcow2-util-linux-cdd5badafd0be42f999ca1e0d69225fff2190472.tar.xz
kernel-qcow2-util-linux-cdd5badafd0be42f999ca1e0d69225fff2190472.zip
libblkid: don't return empty LABELs
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r--shlibs/blkid/src/probe.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c
index f8610cb61..0324351ab 100644
--- a/shlibs/blkid/src/probe.c
+++ b/shlibs/blkid/src/probe.c
@@ -848,6 +848,25 @@ struct blkid_prval *blkid_probe_assign_value(
return v;
}
+int blkid_probe_reset_last_value(blkid_probe pr)
+{
+ struct blkid_prval *v;
+
+ if (pr == NULL || pr->nvals == 0)
+ return -1;
+
+ v = &pr->vals[pr->nvals - 1];
+
+ DBG(DEBUG_LOWPROBE,
+ printf("un-assigning %s [%s]\n", v->name, v->chain->driver->name));
+
+ memset(v, 0, sizeof(struct blkid_prval));
+ pr->nvals--;
+
+ return 0;
+
+}
+
int blkid_probe_set_value(blkid_probe pr, const char *name,
unsigned char *data, size_t len)
{
@@ -878,7 +897,7 @@ int blkid_probe_vsprintf_value(blkid_probe pr, const char *name,
len = vsnprintf((char *) v->data, sizeof(v->data), fmt, ap);
if (len <= 0) {
- pr->nvals--; /* reset the latest assigned value */
+ blkid_probe_reset_last_value(pr);
return -1;
}
v->len = len + 1;