mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 19:47:31 +00:00
Fix incorrect ragg2 empty string check (#17202)
* Check for empty path string only if |file| actually exists * Add a test that would have spot this bug in first place
This commit is contained in:
parent
b027858c95
commit
3f0cfff3d5
@ -343,13 +343,6 @@ R_API int r_main_ragg2(int argc, const char **argv) {
|
||||
file = argv[opt.ind];
|
||||
}
|
||||
|
||||
if (R_STR_ISEMPTY (opt.arg)) {
|
||||
eprintf ("Cannot open empty path\n");
|
||||
free (sequence);
|
||||
r_egg_free (egg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (bits == 64) {
|
||||
if (!strcmp (format, "mach0")) {
|
||||
format = "mach064";
|
||||
@ -378,6 +371,10 @@ R_API int r_main_ragg2(int argc, const char **argv) {
|
||||
// initialize egg
|
||||
r_egg_setup (egg, arch, bits, 0, os);
|
||||
if (file) {
|
||||
if (R_STR_ISEMPTY (file)) {
|
||||
eprintf ("Cannot open empty path\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!strcmp (file, "-")) {
|
||||
char buf[1024];
|
||||
for (;;) {
|
||||
|
@ -147,7 +147,7 @@ EOF
|
||||
RUN
|
||||
|
||||
NAME=ragg2 empty include
|
||||
FILE=-
|
||||
FILE=bins/other/ragg2/hi.c
|
||||
CMDS=!ragg2 -I "" bins/other/ragg2/hi.c
|
||||
EXPECT_ERR=<<EOF
|
||||
Cannot open empty include path
|
||||
@ -155,9 +155,25 @@ EOF
|
||||
RUN
|
||||
|
||||
NAME=ragg2 empty contents
|
||||
FILE=-
|
||||
FILE=bins/other/ragg2/hi.c
|
||||
CMDS=!ragg2 -C "" bins/other/ragg2/hi.c
|
||||
EXPECT_ERR=<<EOF
|
||||
Cannot open empty contents path
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=ragg2 debruijn sequence 1
|
||||
FILE=-
|
||||
CMDS=!ragg2 -r -P 2; ?e
|
||||
EXPECT=<<EOF
|
||||
AA
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=ragg2 debruijn sequence 2
|
||||
FILE=-
|
||||
CMDS=!ragg2 -P 2 -r; ?e
|
||||
EXPECT=<<EOF
|
||||
AA
|
||||
EOF
|
||||
RUN
|
||||
|
Loading…
Reference in New Issue
Block a user