Skip to content

Commit

Permalink
syslogd use "non-string" instead of panicking if the workload or any …
Browse files Browse the repository at this point in the history
…system component logs non string.

Folks from other team reached out to me to see if I have seen an issue where syslogd crashes (they were trying to debug but they couldn't get the logs).
Surely enough it was very easy to reproduce.
Just add the following to the workload:
LOG(INFO) << "\x01\x02\x03\x04\x05\x06\x01\xff\xff\xff\xff";

https://screenshot.googleplex.com/5XAgWWpxZVZZJ9h

Not sure what is the best way to handle string conversion errors here, should we bail from the function ? or just pass in "non-string".
Feedbacks are greatly appreciated.

Change-Id: I6b7186dcdc2df935e1b84d9c3a1afa260f09d295
  • Loading branch information
alwabel1 committed Oct 11, 2024
1 parent 94922a9 commit c5190c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions oak_containers/syslogd/src/systemd_journal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ impl Journal {
let (name, value) =
field.split_at(field.iter().position(|x| *x == b'=').unwrap_or(0));
fields.insert(
std::str::from_utf8(name).unwrap().to_string(),
std::str::from_utf8(&value[1..]).unwrap().to_string(),
std::str::from_utf8(name).unwrap_or("non-string").to_string(),
std::str::from_utf8(&value[1..]).unwrap_or("non-string").to_string(),
);
}

Expand Down

0 comments on commit c5190c0

Please sign in to comment.