summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab_parse.c
diff options
context:
space:
mode:
authorKarel Zak2013-04-12 12:35:34 +0200
committerKarel Zak2013-04-12 12:35:34 +0200
commit4569bbeab783632c81ee14793da84b3e29444543 (patch)
treeb165e3f418600bef11edbd962bc7f76b9d95113f /libmount/src/tab_parse.c
parentbuild-sys: release++ (v2.23-rc2) (diff)
downloadkernel-qcow2-util-linux-4569bbeab783632c81ee14793da84b3e29444543.tar.gz
kernel-qcow2-util-linux-4569bbeab783632c81ee14793da84b3e29444543.tar.xz
kernel-qcow2-util-linux-4569bbeab783632c81ee14793da84b3e29444543.zip
libmount: fix mount.nfs segfault, rely on assert() rather than on nonnull
We use mnt_optstr_append_option(&o, mnt_fs_get_vfs_options(fs), NULL); in mount.nfs, unfortunately mnt_optstr_append_option() has been marked ass nonnull(1, 2). That's wrong because append and prepend should robust enough to accept NULL as option name. The patch also removes almost all __attribute__((nonnull). It seems better to rely on assert() to have usable feedback. In many cases (nonnull) is premature optimization for the library. This attribute makes sense for things like strlen() or so... Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=948274 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_parse.c')
-rw-r--r--libmount/src/tab_parse.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 7368d8c98..e930fd841 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -720,7 +720,6 @@ struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt)
struct stat st;
assert(filename);
-
if (!filename)
return NULL;
if (stat(filename, &st))
@@ -749,6 +748,7 @@ struct libmnt_table *__mnt_new_table_from_file(const char *filename, int fmt)
*/
struct libmnt_table *mnt_new_table_from_file(const char *filename)
{
+ assert(filename);
return __mnt_new_table_from_file(filename, MNT_FMT_GUESS);
}
@@ -763,7 +763,6 @@ struct libmnt_table *mnt_new_table_from_dir(const char *dirname)
struct libmnt_table *tb;
assert(dirname);
-
if (!dirname)
return NULL;
tb = mnt_new_table();
@@ -793,6 +792,7 @@ struct libmnt_table *mnt_new_table_from_dir(const char *dirname)
int mnt_table_set_parser_errcb(struct libmnt_table *tb,
int (*cb)(struct libmnt_table *tb, const char *filename, int line))
{
+ assert(tb);
if (!tb)
return -EINVAL;
tb->errcb = cb;
@@ -807,6 +807,7 @@ int mnt_table_set_parser_fltrcb(struct libmnt_table *tb,
int (*cb)(struct libmnt_fs *, void *),
void *data)
{
+ assert(tb);
if (!tb)
return -EINVAL;
@@ -862,7 +863,6 @@ int mnt_table_parse_fstab(struct libmnt_table *tb, const char *filename)
int rc = 0;
assert(tb);
-
if (!tb)
return -EINVAL;
if (!filename)
@@ -959,6 +959,8 @@ int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename)
const char *utab = NULL;
struct libmnt_table *u_tb;
+ assert(tb);
+
if (mnt_has_regular_mtab(&filename, NULL)) {
DBG(TAB, mnt_debug_h(tb, "force %s usage", filename));