Skip to content

Commit

Permalink
Output secret directly to stdout without parsing it as UTF-8 first. See
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Aug 2, 2017
1 parent 9feb07b commit 167a8a3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ mod cli;

use std::path::Path;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std::io::{self, Read, Write};

fn main() {
if let Err(ref e) = run() {
Expand Down Expand Up @@ -169,11 +168,13 @@ fn recover(shares_paths: Vec<&Path>, output_path: Option<&Path>, verbose: bool)
.chain_err(|| "Could not write secret to file")?;
}
None => {
let secret_str = String::from_utf8(secret)
.chain_err(
|| "Could not parse secret as UTF-8, consider outputting it to a file instead",
)?;
println!("{}", secret_str);
// See https://github.com/romac/rustysecrets-cli/issues/9
// let secret_str = String::from_utf8(secret)
// .chain_err(|| "Could not parse secret as UTF-8, consider outputting it to a file instead")?;

io::stdout()
.write_all(&secret)
.chain_err(|| "Could not write output to stdout")?;
}
}

Expand Down

0 comments on commit 167a8a3

Please sign in to comment.