summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab.c
diff options
context:
space:
mode:
authorKarel Zak2013-03-27 16:47:46 +0100
committerKarel Zak2013-03-27 16:47:46 +0100
commit4cd271adc1dd3231e705c9e074491a7f49a721b8 (patch)
treef3eb0558e01adb764423b8b2fb69c85122b0ba0f /libmount/src/tab.c
parentwipefs: make do_wipe() more readable [coverity scan] (diff)
downloadkernel-qcow2-util-linux-4cd271adc1dd3231e705c9e074491a7f49a721b8.tar.gz
kernel-qcow2-util-linux-4cd271adc1dd3231e705c9e074491a7f49a721b8.tar.xz
kernel-qcow2-util-linux-4cd271adc1dd3231e705c9e074491a7f49a721b8.zip
libmount: make mnt_table_find_* more robust [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab.c')
-rw-r--r--libmount/src/tab.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libmount/src/tab.c b/libmount/src/tab.c
index f70ed7de0..9d524c1c1 100644
--- a/libmount/src/tab.c
+++ b/libmount/src/tab.c
@@ -444,6 +444,8 @@ struct libmnt_fs *mnt_table_find_mountpoint(struct libmnt_table *tb,
if (!tb || !path)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup MOUNTPOINT: %s", path));
@@ -494,6 +496,8 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
if (!tb || !path)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup TARGET: %s", path));
@@ -564,6 +568,8 @@ struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, const char *pa
assert(tb);
if (!tb || !path)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup srcpath: %s", path));
@@ -668,6 +674,8 @@ struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag,
if (!tb || !tag || !val)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup by TAG: %s %s", tag, val));
@@ -710,6 +718,8 @@ struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb,
if (!tb)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s", source));
@@ -753,6 +763,8 @@ struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, const char *sourc
if (!tb || !target)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup SOURCE: %s TARGET: %s", source, target));
@@ -788,6 +800,8 @@ struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb,
if (!tb)
return NULL;
+ if (direction != MNT_ITER_FORWARD && direction != MNT_ITER_BACKWARD)
+ return NULL;
DBG(TAB, mnt_debug_h(tb, "lookup DEVNO: %d", (int) devno));