mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
Expand build_path() function to handle empty dir arguments gracefully
When passing an empty string as a directory, the function would produce filenames starting with a slash even when the given file_name is not an absolute path. Defaulting to the root directory is likely never intended and might conveivably be dangerous. The middle "/" is now skipped also if dir is an empty string.
This commit is contained in:
parent
4d1b9f4a08
commit
9d59a48ae2
3 changed files with 14 additions and 7 deletions
|
@ -50,8 +50,10 @@ print build_path_compressed("/home/bro/", "/usr/local/bro/share/bro/somefile.zee
|
|||
print build_path_compressed("/home/bro/", "/usr/local/bro/share/../../bro/somefile.zeek");
|
||||
|
||||
print "===============================";
|
||||
print "test build_full_path()";
|
||||
print "test build_path()";
|
||||
print "===============================";
|
||||
print build_path("/home/bro/", "policy/somefile.zeek");
|
||||
print build_path("/home/bro/", "/usr/local/bro/share/bro/somefile.zeek");
|
||||
|
||||
print build_path("", "policy/somefile.zeek");
|
||||
print build_path("", "/usr/local/bro/share/bro/somefile.zeek");
|
||||
print build_path("/", "policy/somefile.zeek");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue