diff options
author | Karel Zak | 2013-06-17 13:02:15 +0200 |
---|---|---|
committer | Karel Zak | 2013-06-17 13:02:15 +0200 |
commit | 7ba207e781c7af3945d3a718651b87425685131e (patch) | |
tree | d8edf4afc0d81a68f94a68c5421b4446677e70c2 /lib/canonicalize.c | |
parent | libblkid: support pseudo PARTUUID= for MBR (diff) | |
download | kernel-qcow2-util-linux-7ba207e781c7af3945d3a718651b87425685131e.tar.gz kernel-qcow2-util-linux-7ba207e781c7af3945d3a718651b87425685131e.tar.xz kernel-qcow2-util-linux-7ba207e781c7af3945d3a718651b87425685131e.zip |
libmount: be robust for empty target/source strings
* lib/canonicalize.c: don't interpret empty strings as relative paths
* libmount: more robust libmnt_table find function and debug messages
References: https://bugzilla.novell.com/show_bug.cgi?id=825150
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib/canonicalize.c')
-rw-r--r-- | lib/canonicalize.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 727806e1e..548e29b75 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -151,6 +151,9 @@ canonicalize_dm_name(const char *ptname) size_t sz; char path[256], name[256], *res = NULL; + if (!ptname || !*ptname) + return NULL; + snprintf(path, sizeof(path), "/sys/block/%s/dm/name", ptname); if (!(f = fopen(path, "r" UL_CLOEXECSTR))) return NULL; @@ -173,7 +176,7 @@ canonicalize_path(const char *path) char canonical[PATH_MAX+2]; char *p; - if (path == NULL) + if (!path || !*path) return NULL; if (!myrealpath(path, canonical, PATH_MAX+1)) @@ -199,7 +202,7 @@ canonicalize_path_restricted(const char *path) uid_t euid; gid_t egid; - if (path == NULL) + if (!path || !*path) return NULL; euid = geteuid(); |