diff options
author | Lee Duncan <leeman.duncan@gmail.com> | 2018-03-22 10:48:00 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-22 10:48:00 -0700 |
commit | 2c980e77c9d3f97a2abcfea070fae71e804df22c (patch) | |
tree | e4d087fa65202ff8357304732d5fafec206ef44f /libopeniscsiusr | |
parent | 8c0eb3e6c34233fbecddd76c881bdcd0daaf91b9 (diff) | |
parent | 57d099008a489de506062761d4c7359e84240e47 (diff) | |
download | open-iscsi-2c980e77c9d3f97a2abcfea070fae71e804df22c.tar.gz |
Merge branch 'master' into api
Diffstat (limited to 'libopeniscsiusr')
-rw-r--r-- | libopeniscsiusr/Makefile | 2 | ||||
-rw-r--r-- | libopeniscsiusr/iface.c | 1 | ||||
-rw-r--r-- | libopeniscsiusr/sysfs.c | 14 |
3 files changed, 14 insertions, 3 deletions
diff --git a/libopeniscsiusr/Makefile b/libopeniscsiusr/Makefile index 05a77da..754ffb7 100644 --- a/libopeniscsiusr/Makefile +++ b/libopeniscsiusr/Makefile @@ -49,7 +49,7 @@ LIBADD = all: $(LIBS) $(LIBS_MAJOR) $(TESTS) doc $(LIBS): $(OBJS) - $(CC) $(LDFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS) $(LIBADD) + $(CC) $(CFLAGS) $(LDFLAGS) -shared -Wl,-soname=$@ -o $@ $(OBJS) $(LIBADD) ln -sf $@ $(DEVLIB) $(LIBS_MAJOR): $(LIBS) diff --git a/libopeniscsiusr/iface.c b/libopeniscsiusr/iface.c index 5cccbf2..3233bb5 100644 --- a/libopeniscsiusr/iface.c +++ b/libopeniscsiusr/iface.c @@ -36,6 +36,7 @@ #ifdef USE_KMOD #include <libkmod.h> #endif +#include <limits.h> #include "libopeniscsiusr/libopeniscsiusr.h" #include "misc.h" diff --git a/libopeniscsiusr/sysfs.c b/libopeniscsiusr/sysfs.c index f568245..22eaf44 100644 --- a/libopeniscsiusr/sysfs.c +++ b/libopeniscsiusr/sysfs.c @@ -325,6 +325,8 @@ int _iscsi_host_id_of_session(struct iscsi_context *ctx, uint32_t sid, struct dirent **namelist = NULL; int n = 0; const char *host_id_str = NULL; + const char iscsi_host_dir_str[] = "/iscsi_host/"; + const unsigned int iscsi_host_dir_strlen = strlen(iscsi_host_dir_str); assert(ctx != NULL); assert(sid != 0); @@ -339,8 +341,16 @@ int _iscsi_host_id_of_session(struct iscsi_context *ctx, uint32_t sid, _SYSFS_DEV_CLASS_ISCSI_SESSION, sys_dev_path), rc, out); - snprintf(sys_scsi_host_dir_path, PATH_MAX, "%s/iscsi_host/", - sys_dev_path); + if ((strlen(sys_dev_path) + iscsi_host_dir_strlen) >= PATH_MAX) { + rc = LIBISCSI_ERR_SYSFS_LOOKUP; + _error(ctx, "Pathname too long: %s%s", + sys_dev_path, iscsi_host_dir_str); + goto out; + } + + strncpy(sys_scsi_host_dir_path, sys_dev_path, PATH_MAX); + strncat(sys_scsi_host_dir_path, iscsi_host_dir_str, + PATH_MAX - iscsi_host_dir_strlen); _good(_scandir(ctx, sys_scsi_host_dir_path, &namelist, &n), rc, out); |