diff options
author | Sami Kerola | 2019-07-12 23:28:10 +0200 |
---|---|---|
committer | Sami Kerola | 2019-07-14 12:52:13 +0200 |
commit | f3aded3fdb1e19818b05f205b74cd4bff7532811 (patch) | |
tree | d96f40e8f6a1cdc7d51c28743be07dd51a7347c8 /misc-utils | |
parent | libmount: fix potential null pointer dereference (diff) | |
download | kernel-qcow2-util-linux-f3aded3fdb1e19818b05f205b74cd4bff7532811.tar.gz kernel-qcow2-util-linux-f3aded3fdb1e19818b05f205b74cd4bff7532811.tar.xz kernel-qcow2-util-linux-f3aded3fdb1e19818b05f205b74cd4bff7532811.zip |
include/xalloc: ensure xstrdup() and xstrndup() returns nonnull attribute
Turned out lsblk is passing null as argument to xstrdup(), so fix that and
add assert() to make sure promise of not returning null is kept in future.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils')
-rw-r--r-- | misc-utils/lsblk.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 3ce6da730..7ab9dc23c 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -774,8 +774,14 @@ static char *device_get_data( str = get_vfs_attribute(dev, id); break; case COL_TARGET: - str = xstrdup(lsblk_device_get_mountpoint(dev)); + { + char *s = lsblk_device_get_mountpoint(dev); + if (s) + str = xstrdup(s); + else + str = NULL; break; + } case COL_LABEL: prop = lsblk_device_get_properties(dev); if (prop && prop->label) |