Do not depend on strlcpy/strlcat

This commit is contained in:
Todd C. Miller
2010-07-05 16:49:25 -04:00
parent 6a058e4af9
commit 47c28e7ece

View File

@@ -75,27 +75,19 @@ group_plugin_load(char *plugin_info)
{ {
char *args, path[PATH_MAX], savedch; char *args, path[PATH_MAX], savedch;
char **argv = NULL; char **argv = NULL;
size_t len;
int rc; int rc;
/* /*
* Fill in .so path and split out args (if any). * Fill in .so path and split out args (if any).
*/ */
path[0] = '\0';
if (plugin_info[0] != '/')
strlcpy(path, "./", sizeof(path));
if ((args = strpbrk(plugin_info, " \t")) != NULL) { if ((args = strpbrk(plugin_info, " \t")) != NULL) {
savedch = *args; savedch = *args;
*args = '\0'; *args = '\0';
} }
len = strlcat(path, plugin_info, sizeof(path)); strncpy(path, plugin_info, sizeof(path) - 1);
path[sizeof(path) - 1] = '\0';
if (args != NULL) if (args != NULL)
*args++ = savedch; *args++ = savedch;
if (len >= sizeof(path)) {
fprintf(stderr, "%s%s: %s\n", "./", plugin_info,
strerror(ENAMETOOLONG));
return -1;
}
/* Open plugin and map in symbol. */ /* Open plugin and map in symbol. */
group_handle = dlopen(path, RTLD_LAZY); group_handle = dlopen(path, RTLD_LAZY);