summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab_update.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_update.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_update.c')
-rw-r--r--libmount/src/tab_update.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
index 044a13f5e..1e7f32be0 100644
--- a/libmount/src/tab_update.c
+++ b/libmount/src/tab_update.c
@@ -131,6 +131,7 @@ int mnt_update_set_filename(struct libmnt_update *upd, const char *filename,
*/
const char *mnt_update_get_filename(struct libmnt_update *upd)
{
+ assert(upd);
return upd ? upd->filename : NULL;
}
@@ -143,6 +144,7 @@ const char *mnt_update_get_filename(struct libmnt_update *upd)
*/
int mnt_update_is_ready(struct libmnt_update *upd)
{
+ assert(upd);
return upd ? upd->ready : FALSE;
}
@@ -227,6 +229,7 @@ int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags,
*/
struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd)
{
+ assert(upd);
return upd ? upd->fs : NULL;
}
@@ -238,6 +241,7 @@ struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd)
*/
unsigned long mnt_update_get_mflags(struct libmnt_update *upd)
{
+ assert(upd);
return upd ? upd->mountflags : 0;
}
@@ -252,6 +256,7 @@ int mnt_update_force_rdonly(struct libmnt_update *upd, int rdonly)
{
int rc = 0;
+ assert(upd);
if (!upd || !upd->fs)
return -EINVAL;
@@ -505,6 +510,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb)
int rc, fd;
char *uq = NULL;
+ assert(upd);
if (!tb || !upd->filename)
return -EINVAL;
@@ -566,8 +572,11 @@ leave:
static int add_file_entry(struct libmnt_table *tb, struct libmnt_update *upd)
{
- struct libmnt_fs *fs = mnt_copy_fs(NULL, upd->fs);
+ struct libmnt_fs *fs;
+
+ assert(upd);
+ fs = mnt_copy_fs(NULL, upd->fs);
if (!fs)
return -ENOMEM;
@@ -638,6 +647,7 @@ static int update_modify_target(struct libmnt_update *upd, struct libmnt_lock *l
struct libmnt_table *tb = NULL;
int rc = 0;
+ assert(upd);
DBG(UPDATE, mnt_debug_h(upd, "%s: modify target", upd->filename));
if (lc)
@@ -726,7 +736,6 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc)
int rc = -EINVAL;
assert(upd);
-
if (!upd || !upd->filename)
return -EINVAL;
if (!upd->ready)