Simplify module path list, removing strcpy use.
This commit is contained in:
parent
b84e58f905
commit
26c6ac3dc7
2 changed files with 7 additions and 14 deletions
|
@ -52,11 +52,6 @@ struct module
|
|||
void * mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
|
||||
};
|
||||
|
||||
struct module_path
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
};
|
||||
|
||||
#define MAPI_MAGIC_HDR 0x4D410000
|
||||
|
||||
#define MAPI_V1 (MAPI_MAGIC_HDR | 0x1)
|
||||
|
|
|
@ -130,17 +130,17 @@ modules_init(void)
|
|||
* output - none
|
||||
* side effects - returns a module path from path
|
||||
*/
|
||||
static struct module_path *
|
||||
static char *
|
||||
mod_find_path(const char *path)
|
||||
{
|
||||
rb_dlink_node *ptr;
|
||||
struct module_path *mpath;
|
||||
char *mpath;
|
||||
|
||||
RB_DLINK_FOREACH(ptr, mod_paths.head)
|
||||
{
|
||||
mpath = ptr->data;
|
||||
|
||||
if(!strcmp(path, mpath->path))
|
||||
if(!strcmp(path, mpath))
|
||||
return mpath;
|
||||
}
|
||||
|
||||
|
@ -156,14 +156,12 @@ mod_find_path(const char *path)
|
|||
void
|
||||
mod_add_path(const char *path)
|
||||
{
|
||||
struct module_path *pathst;
|
||||
char *pathst;
|
||||
|
||||
if(mod_find_path(path))
|
||||
return;
|
||||
|
||||
pathst = rb_malloc(sizeof(struct module_path));
|
||||
|
||||
strcpy(pathst->path, path);
|
||||
pathst = rb_strdup(path);
|
||||
rb_dlinkAddAlloc(pathst, &mod_paths);
|
||||
}
|
||||
|
||||
|
@ -288,7 +286,7 @@ load_one_module(const char *path, int coremodule)
|
|||
{
|
||||
char modpath[PATH_MAX];
|
||||
rb_dlink_node *pathst;
|
||||
struct module_path *mpath;
|
||||
const char *mpath;
|
||||
|
||||
struct stat statbuf;
|
||||
|
||||
|
@ -299,7 +297,7 @@ load_one_module(const char *path, int coremodule)
|
|||
{
|
||||
mpath = pathst->data;
|
||||
|
||||
rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath->path, path);
|
||||
rb_snprintf(modpath, sizeof(modpath), "%s/%s", mpath, path);
|
||||
if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL))
|
||||
{
|
||||
if(stat(modpath, &statbuf) == 0)
|
||||
|
|
Loading…
Reference in a new issue