From: Unsung Lee Date: Tue, 29 Aug 2023 02:33:50 +0000 (+0900) Subject: block: Check return value of udev_device_get_syspath() X-Git-Tag: accepted/tizen/8.0/unified/20231005.093850^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8de8531ecf5dca05b1737a9d34ab4cab7649a742;p=platform%2Fcore%2Fsystem%2Fstoraged.git block: Check return value of udev_device_get_syspath() Check return value of udev_device_get_syspath() to avoid passing NULL parameter in rindex() function. This solves bug reported by SVACE with WGID 540346. Change-Id: Ic795e66c7b220ab1c5ced33901c86befb1e6f7db Signed-off-by: Unsung Lee --- diff --git a/src/block/block.c b/src/block/block.c index 6e72ab6..e70f462 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -2193,9 +2193,14 @@ static int add_block_device(struct udev_device *dev, const char *devnode, bool e if (extended_internal && !udev_device_get_property_value(dev, "ID_FS_TYPE")) { char syspath[128] = {0}; + const char *path; char *r; - r = rindex(udev_device_get_syspath(dev), '/'); + path = udev_device_get_syspath(dev); + if (!path) + return -ENODEV; + + r = rindex(path, '/'); if (!r) return -ENODEV; snprintf(syspath, sizeof(syspath), "/sys/block%s", r);