diff options
author | Karel Zak | 2012-01-31 13:25:00 +0100 |
---|---|---|
committer | Karel Zak | 2012-01-31 13:25:00 +0100 |
commit | a2b9ff9a706253d00f4180b11b6eee9b378da1ec (patch) | |
tree | 47d9db0df18a84feb9f1cb784e1a4b7f3c9544e4 /libblkid | |
parent | mkswap: check blkid_probe_lookup_values() return [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-a2b9ff9a706253d00f4180b11b6eee9b378da1ec.tar.gz kernel-qcow2-util-linux-a2b9ff9a706253d00f4180b11b6eee9b378da1ec.tar.xz kernel-qcow2-util-linux-a2b9ff9a706253d00f4180b11b6eee9b378da1ec.zip |
libblkid: check return values in safe_probe code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid')
-rw-r--r-- | libblkid/src/superblocks/superblocks.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index dbdce8b51..ea50dbc39 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -344,6 +344,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) const struct blkid_idinfo *id; const struct blkid_idmag *mag = NULL; blkid_loff_t off = 0; + int rc = 0; chn->idx = i; id = idinfos[i]; @@ -383,15 +384,21 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn) /* all cheks passed */ if (chn->flags & BLKID_SUBLKS_TYPE) - blkid_probe_set_value(pr, "TYPE", + rc = blkid_probe_set_value(pr, "TYPE", (unsigned char *) id->name, strlen(id->name) + 1); - blkid_probe_set_usage(pr, id->usage); + if (!rc) + rc = blkid_probe_set_usage(pr, id->usage); - if (mag) - blkid_probe_set_magic(pr, off, mag->len, + if (!rc && mag) + rc = blkid_probe_set_magic(pr, off, mag->len, (unsigned char *) mag->magic); + if (rc) { + blkid_probe_chain_reset_vals(pr, chn); + DBG(DEBUG_LOWPROBE, printf("failed to set result -- ingnore\n")); + continue; + } DBG(DEBUG_LOWPROBE, printf("<-- leaving probing loop (type=%s) [SUBLKS idx=%d]\n", |