summaryrefslogtreecommitdiffstats
path: root/libmount/src/utils.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/utils.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/utils.c')
-rw-r--r--libmount/src/utils.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index c910035df..c328414f2 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -269,6 +269,8 @@ int mnt_fstype_is_pseudofs(const char *type)
"tmpfs"
};
+ assert(type);
+
return !(bsearch(&type, pseudofs, ARRAY_SIZE(pseudofs),
sizeof(char*), fstype_cmp) == NULL);
}
@@ -281,6 +283,8 @@ int mnt_fstype_is_pseudofs(const char *type)
*/
int mnt_fstype_is_netfs(const char *type)
{
+ assert(type);
+
if (strcmp(type, "cifs") == 0 ||
strcmp(type, "smbfs") == 0 ||
strncmp(type,"nfs", 3) == 0 ||
@@ -859,10 +863,13 @@ int mnt_open_uniq_filename(const char *filename, char **name)
*/
char *mnt_get_mountpoint(const char *path)
{
- char *mnt = strdup(path);
+ char *mnt;
struct stat st;
dev_t dir, base;
+ assert(path);
+
+ mnt = strdup(path);
if (!mnt)
return NULL;
if (*mnt == '/' && *(mnt + 1) == '\0')