Skip to content
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

fixes TOCTOU bug in bap log #937

Merged
merged 4 commits into from
Apr 2, 2019

Conversation

gitoleg
Copy link
Contributor

@gitoleg gitoleg commented Mar 28, 2019

fixes #722

lib/bap/bap_log.ml Outdated Show resolved Hide resolved
@@ -54,13 +54,26 @@ let print_message ppf msg =
| Error -> eprintf "%s@\n%!" msg.message
| _ -> ()

let lock () =
let file = Filename.get_temp_dir_name () / "bap_lock" in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. bap.lock is a much more conventional name
  2. this lock file would be global to all users, so my suggestion is to encode in the name of the lock file the path to the folder, that you're trying to create, salted with bap-prefix, the simplest idea is to take the digest of the path, e.g,
let lock_filename logdir = 
    let digest = Md5.digest_string logdir in
    let name = sprintf "bap-%s.lock" (Md5.to_hex digest) in
    Filename.get_temp_dir_name () / name

@gitoleg gitoleg merged commit 1554ffd into BinaryAnalysisPlatform:master Apr 2, 2019
@gitoleg gitoleg deleted the fix-log-toctou branch May 13, 2020 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Revise the logging infrastructure
2 participants