#3692: review — doc comments on the functions the Zotero hardening added or changed

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CX1hMKX28764Lrx5moxs1o
This commit is contained in:
Martin BallandClaude Opus 5.5 committed 2026-10-25 23:49:15 +00:00
1 parent 65f3c3418f
commit e251c960d9
4 files changed
+10

No files matched your search

+2
View File
@@ -387,6 +387,8 @@ fn valid_connect_addr(addr: &str) -> bool {
!host.is_empty() && port.parse::<u16>().is_ok()
}
/// Run the subcommand named by `args` (the command line after the program name). Files named
/// there are opened by their real names, which may not be valid Unicode.
fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
let script_path = script_operand(args);
let (args, file) = text_args(args)?;
+1
View File
@@ -194,6 +194,7 @@ impl Bridge {
}
}
/// Answer one call by its method name; [`Bridge::handle`] wraps it so a panic becomes an error.
fn dispatch(&mut self, s: &mut Session, host: &mut dyn Host, c: &Call) -> R {
match c.method.as_str() {
"Application_getActiveDocument" => {
+4
View File
@@ -29,6 +29,7 @@ pub(crate) fn check(stream: &TcpStream) -> Result<(), ZoteroError> {
owner_check(local, peer)
}
/// Refuse a listener at `peer` that the kernel's socket tables say belongs to another user.
#[cfg(any(target_os = "linux", target_os = "android"))]
fn owner_check(local: SocketAddr, peer: SocketAddr) -> Result<(), ZoteroError> {
use std::io::Read;
@@ -48,6 +49,7 @@ fn owner_check(local: SocketAddr, peer: SocketAddr) -> Result<(), ZoteroError> {
same_owner(&table, local, peer, me)
}
/// No socket table to read here: the loopback rule alone decides.
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn owner_check(_local: SocketAddr, _peer: SocketAddr) -> Result<(), ZoteroError> {
Ok(())
@@ -124,12 +126,14 @@ mod tests {
format!("{ip}:{:04X}", a.port())
}
/// A socket table row for the connection from `l` to `r`, owned by `uid`.
fn row(l: SocketAddr, r: SocketAddr, uid: u32) -> String {
format!(" 0: {} {} 01 00000000:00000000 00:00000000 00000000 {uid:>4} 0 12345 1 0000000000000000 20 4 30 10 -1\n", hex(l), hex(r))
}
const HEADER: &str = " sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode\n";
/// Our side and Zotero's listening side of a loopback connection.
fn addrs() -> (SocketAddr, SocketAddr) {
("127.0.0.1:41234".parse().unwrap(), "127.0.0.1:23116".parse().unwrap())
}
+3
View File
@@ -40,6 +40,9 @@ fn style_props(base: &CharProps, src: &CharProps) -> CharProps {
p
}
/// The body paragraphs of `d` (Zotero's RTF or HTML, read), at most [`MAX_PARAS`], formatted on
/// top of `base` with the run styling they carry (past [`MAX_RUNS`] runs, text keeps the
/// formatting before it). Objects are dropped.
fn from_doc(d: &Document, base: &CharProps) -> Vec<Paragraph> {
let mut out = Vec::new();
let mut runs = 0usize;