summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/lib/cfgadm_plugins/sata/common/cfga_sata.c6
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/sata/sata.c8
2 files changed, 10 insertions, 4 deletions
diff --git a/usr/src/lib/cfgadm_plugins/sata/common/cfga_sata.c b/usr/src/lib/cfgadm_plugins/sata/common/cfga_sata.c
index 0973818b28..9c245e9bd8 100644
--- a/usr/src/lib/cfgadm_plugins/sata/common/cfga_sata.c
+++ b/usr/src/lib/cfgadm_plugins/sata/common/cfga_sata.c
@@ -280,7 +280,8 @@ physpath_to_devlink(const char *basedir, const char *node_path,
buf = malloc(PATH_MAX);
real_path = malloc(PATH_MAX);
- deplen = pathconf(basedir, _PC_NAME_MAX) +
+ deplen = pathconf(basedir, _PC_NAME_MAX);
+ deplen = (deplen <= 0 ? MAXNAMELEN : deplen) +
sizeof (struct dirent);
dep = (struct dirent *)malloc(deplen);
@@ -1185,7 +1186,8 @@ sata_make_dyncomp(const char *ap_id, char **dyncomp)
* struct dirent includes one byte (the terminator)
* so we don't add 1 to the calculation here.
*/
- deplen = pathconf(devpath, _PC_NAME_MAX) +
+ deplen = pathconf(devpath, _PC_NAME_MAX);
+ deplen = ((deplen <= 0) ? MAXNAMELEN : deplen) +
sizeof (struct dirent);
dep = (struct dirent *)malloc(deplen);
if (dep == NULL)
diff --git a/usr/src/lib/fm/topo/modules/i86pc/sata/sata.c b/usr/src/lib/fm/topo/modules/i86pc/sata/sata.c
index e4c6e5cee2..890626736b 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/sata/sata.c
+++ b/usr/src/lib/fm/topo/modules/i86pc/sata/sata.c
@@ -567,7 +567,9 @@ find_physical_disk_node(char *physpath, int pathbuflen, int portnum,
* in the devfs filesystem. The NUL byte is accounted-for in the
* 1 byte already allocated as part of d_name in the dirent structure.
*/
- dentlen = sizeof (struct dirent) + pathconf(physpath, _PC_NAME_MAX);
+ dentlen = pathconf(physpath, _PC_NAME_MAX);
+ dentlen = ((dentlen <= 0) ? MAXNAMELEN : dentlen) +
+ sizeof (struct dirent);
dent = topo_mod_alloc(mod, dentlen);
errno = 0;
@@ -622,7 +624,9 @@ sata_maximum_port(char *dpath, topo_mod_t *mod)
* in the devfs filesystem. The NUL byte is accounted-for in the
* 1 byte already allocated as part of d_name in the dirent structure.
*/
- dentlen = sizeof (struct dirent) + pathconf(devpath, _PC_NAME_MAX);
+ dentlen = pathconf(devpath, _PC_NAME_MAX);
+ dentlen = ((dentlen <= 0) ? MAXNAMELEN : dentlen) +
+ sizeof (struct dirent);
dent = topo_mod_alloc(mod, dentlen);
/*