Skip to content

Commit ac9be65

Browse files
committed
fix: validate api input
1 parent 18eaf59 commit ac9be65

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

boringtun/src/device/api.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,12 @@ fn api_set(reader: &mut BufReader<&UnixStream>, d: &mut LockReadGuard<Device>) -
210210
let mut cmd = String::new();
211211

212212
while reader.read_line(&mut cmd).is_ok() {
213-
cmd.pop(); // remove newline if any
213+
let end = cmd.pop(); // remove newline if any
214+
if let Some(end) = end {
215+
if end != '\n' {
216+
return EPROTO;
217+
}
218+
}
214219
if cmd.is_empty() {
215220
return 0; // Done
216221
}

0 commit comments

Comments
 (0)