/* If the first file specification is a rooted path, it rules.
same goes if the second file specification is missing. */
if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) {
- len = strlen(filespec1) + 1;
- merged = malloc(len);
+ merged = strdup(filespec1);
if (!merged) {
DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- strlcpy(merged, filespec1, len);
}
/* If the first file specification is missing, the second one rules. */
else if (!filespec1) {
- len = strlen(filespec2) + 1;
- merged = malloc(strlen(filespec2) + 1);
+ merged = strdup(filespec2);
if (!merged) {
DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- strlcpy(merged, filespec2, len);
} else
/* This part isn't as trivial as it looks. It assumes that
the second file specification really is a directory, and
return (0);
}
/* We'll duplicate filename */
- copied = malloc(strlen(filename) + 1);
+ copied = strdup(filename);
if (copied == NULL) {
DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE);
return (0);
}
- strlcpy(copied, filename, strlen(filename) + 1);
if (dso->filename)
free(dso->filename);
dso->filename = copied;
result = dso->meth->dso_name_converter(dso, filename);
}
if (result == NULL) {
- result = malloc(strlen(filename) + 1);
+ result = strdup(filename);
if (result == NULL) {
DSOerr(DSO_F_DSO_CONVERT_FILENAME,
ERR_R_MALLOC_FAILURE);
return (NULL);
}
- strlcpy(result, filename, strlen(filename) + 1);
}
return (result);
}
/* If the first file specification is a rooted path, it rules.
same goes if the second file specification is missing. */
if (!filespec2 || (filespec1 != NULL && filespec1[0] == '/')) {
- len = strlen(filespec1) + 1;
- merged = malloc(len);
+ merged = strdup(filespec1);
if (!merged) {
DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- strlcpy(merged, filespec1, len);
}
/* If the first file specification is missing, the second one rules. */
else if (!filespec1) {
- len = strlen(filespec2) + 1;
- merged = malloc(strlen(filespec2) + 1);
+ merged = strdup(filespec2);
if (!merged) {
DSOerr(DSO_F_DLFCN_MERGER, ERR_R_MALLOC_FAILURE);
return (NULL);
}
- strlcpy(merged, filespec2, len);
} else
/* This part isn't as trivial as it looks. It assumes that
the second file specification really is a directory, and
return (0);
}
/* We'll duplicate filename */
- copied = malloc(strlen(filename) + 1);
+ copied = strdup(filename);
if (copied == NULL) {
DSOerr(DSO_F_DSO_SET_FILENAME, ERR_R_MALLOC_FAILURE);
return (0);
}
- strlcpy(copied, filename, strlen(filename) + 1);
if (dso->filename)
free(dso->filename);
dso->filename = copied;
result = dso->meth->dso_name_converter(dso, filename);
}
if (result == NULL) {
- result = malloc(strlen(filename) + 1);
+ result = strdup(filename);
if (result == NULL) {
DSOerr(DSO_F_DSO_CONVERT_FILENAME,
ERR_R_MALLOC_FAILURE);
return (NULL);
}
- strlcpy(result, filename, strlen(filename) + 1);
}
return (result);
}