From c446179b11608a25989dea1209fe3341fe17b76d Mon Sep 17 00:00:00 2001
From: Gris Ge <fge@redhat.com>
Date: Thu, 23 Feb 2017 21:41:46 +0800
Subject: [PATCH] C library: Bug fix for incorrect use of sizeof.
* Should use strlen() instead of sizeof() for calculate string length.
Signed-off-by: Gris Ge <fge@redhat.com>
---
c_binding/libses.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/c_binding/libses.c b/c_binding/libses.c
index a5ebb2d..3c1e8d9 100644
--- a/c_binding/libses.c
+++ b/c_binding/libses.c
@@ -341,9 +341,9 @@ static int _ses_sg_paths_get(char *err_msg, char ***sg_paths,
(strncmp(sg_name, "sg", strlen("sg")) != 0))
continue;
sysfs_sg_type_path = (char *)
- malloc(sizeof(char) * (sizeof(_SYSFS_SG_ROOT_PATH) +
+ malloc(sizeof(char) * (strlen(_SYSFS_SG_ROOT_PATH) +
strlen("/") +
- sizeof(sg_name) +
+ strlen(sg_name) +
strlen("/device/type") +
1 /* trailing \0 */));
_alloc_null_check(err_msg, sysfs_sg_type_path, rc, out);
--
1.8.3.1