Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
lib: add a function checking file names
Move the code from ABRT and extend it a bit: * allow only 64 characters * allow '.' in names (vmcore_dmesg.txt) * forbid '/' * forbid "." * forbid ".." Related: #1214451 Signed-off-by: Jakub Filak <jfilak@redhat.com>
- Loading branch information
Jakub Filak
committed
Apr 28, 2015
1 parent
e76a865
commit 54ecf8d
Showing
5 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # -*- Autotest -*- | ||
|
|
||
| AT_BANNER([dump directories]) | ||
|
|
||
| ## ----------------------- ## | ||
| ## str_is_correct_filename ## | ||
| ## ----------------------- ## | ||
|
|
||
| AT_TESTFUN([str_is_correct_filename], | ||
| [[ | ||
| #include "internal_libreport.h" | ||
| #include <assert.h> | ||
| # | ||
| int main(void) | ||
| { | ||
| g_verbose = 3; | ||
|
|
||
| assert(str_is_correct_filename("") == false); | ||
| assert(str_is_correct_filename("/") == false); | ||
| assert(str_is_correct_filename("//") == false); | ||
| assert(str_is_correct_filename(".") == false); | ||
| assert(str_is_correct_filename(".") == false); | ||
| assert(str_is_correct_filename("..") == false); | ||
| assert(str_is_correct_filename("..") == false); | ||
| assert(str_is_correct_filename("/.") == false); | ||
| assert(str_is_correct_filename("//.") == false); | ||
| assert(str_is_correct_filename("./") == false); | ||
| assert(str_is_correct_filename(".//") == false); | ||
| assert(str_is_correct_filename("/./") == false); | ||
| assert(str_is_correct_filename("/..") == false); | ||
| assert(str_is_correct_filename("//..") == false); | ||
| assert(str_is_correct_filename("../") == false); | ||
| assert(str_is_correct_filename("..//") == false); | ||
| assert(str_is_correct_filename("/../") == false); | ||
| assert(str_is_correct_filename("/.././") == false); | ||
|
|
||
| assert(str_is_correct_filename("looks-good-but-evil/") == false); | ||
| assert(str_is_correct_filename("looks-good-but-evil/../../") == false); | ||
|
|
||
| assert(str_is_correct_filename(".meta-data") == true); | ||
| assert(str_is_correct_filename("..meta-meta-data") == true); | ||
| assert(str_is_correct_filename("meta-..-data") == true); | ||
|
|
||
| assert(str_is_correct_filename("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-") == true); | ||
| assert(str_is_correct_filename("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890+-=") == false); | ||
|
|
||
| return 0; | ||
| } | ||
| ]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters