mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
Fixes to relative @load'ing.
The currently loading script's path is prepended (vs. appended) to BROPATH to search for the @load'd file to prevent being overshadowed by scripts/directories/packages in the normal BROPATH with the same name. This extra search path should also only be prepended to BROPATH in the case when the @load'd file we're looking for is actually relative (i.e. the name starts with "./" or "../").
This commit is contained in:
parent
64bc53e621
commit
454fd9578e
1 changed files with 4 additions and 4 deletions
|
@ -972,11 +972,11 @@ FILE* search_for_file(const char* filename, const char* ext,
|
||||||
|
|
||||||
char path[1024], full_filename_buf[1024];
|
char path[1024], full_filename_buf[1024];
|
||||||
|
|
||||||
// Append the currently loading script's path to BROPATH so that
|
// Prepend the currently loading script's path to BROPATH so that
|
||||||
// @loads can be referenced relatively.
|
// @loads can be referenced relatively.
|
||||||
if ( current_scanned_file_path != "" )
|
if ( current_scanned_file_path != "" && filename[0] == '.' )
|
||||||
safe_snprintf(path, sizeof(path), "%s:%s", bro_path(),
|
safe_snprintf(path, sizeof(path), "%s:%s",
|
||||||
current_scanned_file_path.c_str());
|
current_scanned_file_path.c_str(), bro_path());
|
||||||
else
|
else
|
||||||
safe_strncpy(path, bro_path(), sizeof(path));
|
safe_strncpy(path, bro_path(), sizeof(path));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue