New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes an error message in case of empty file #896

Merged
merged 6 commits into from Nov 12, 2018

Conversation

Projects
None yet
2 participants
@gitoleg
Contributor

gitoleg commented Nov 7, 2018

This PR changes an error message if bap is using with an empty file:

$ touch /tmp/foo.txt
$ bap /tmp/foo.txt
Failed to create a project: ("File format is not supported: expected executable, library or kernel module"
  "Raised at file \"src/import0.ml\" (inlined), line 234, characters 22-32\
 \nCalled from file \"src/error.ml\" (inlined), line 9, characters 14-30\
 \nCalled from file \"src/or_error.ml\", line 70, characters 17-32\
 \nCalled from file \"lib/bap/bap_project.ml\", line 264, characters 47-54\
 \nCalled from file \"src/or_error.ml\", line 62, characters 9-15\
 \n")

fix #895

changes an error message in case of empty file
This PR changes an error message if bap is using with an emptyt file:
```
$ touch /tmp/foo.txt
$ bap /tmp/foo.txt
Failed to create a project: ("File format is not supported: expected executable, library or kernel module"
  "Raised at file \"src/import0.ml\" (inlined), line 234, characters 22-32\
 \nCalled from file \"src/error.ml\" (inlined), line 9, characters 14-30\
 \nCalled from file \"src/or_error.ml\", line 70, characters 17-32\
 \nCalled from file \"lib/bap/bap_project.ml\", line 264, characters 47-54\
 \nCalled from file \"src/or_error.ml\", line 62, characters 9-15\
 \n")

```
@ivg
  1. the error message is wrong, as "executables, libraries, and kernel modules" are not formats, moreover whatever we expect is defined by the loaders, so we can't claim this.
  2. the fix affects only llvm, while bap-elf and ida loader behavior will remain the same (whatever it was)
  3. the error message could be made nicer (since you're already here)
  4. the handling of the problem is wrong - you have an empty file, not an unsupported format.

gitoleg added some commits Nov 7, 2018

@gitoleg

This comment has been minimized.

Contributor

gitoleg commented Nov 7, 2018

  1. added a sanity check on the input:
$ touch /tmp/foo.txt
$ bap /tmp/foo
bap: FILE argument: /tmp/foo: file is empty
Usage: bap [OPTION]... FILE
Try `bap --help' for more information.
$
$ bap /bin
bap: FILE argument: /bin: must be a regular file or symlink
Usage: bap [OPTION]... FILE
Try `bap --help' for more information.
$
$ bap some-file
bap some-file
bap: FILE argument: some-file: file not found
Usage: bap [OPTION]... FILE
  1. made a backtrace output a little bit nicer:
$ bap my_broken_file --no-cache
Failed to create a project: File format is not supported
Backtrace:
Raised at file "src/import0.ml" (inlined), line 234, characters 22-32
Called from file "src/error.ml" (inlined), line 9, characters 14-30
Called from file "src/or_error.ml", line 70, characters 17-32
Called from file "lib/bap/bap_project.ml", line 264, characters 47-54
Called from file "src/or_error.ml", line 62, characters 9-15
@ivg

ivg approved these changes Nov 12, 2018

@ivg ivg merged commit a755ec7 into BinaryAnalysisPlatform:master Nov 12, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment