Skip to content

Commit 9b34d74

Browse files
committed
add negative test
1 parent 42fef24 commit 9b34d74

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tokio-postgres/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,4 +1051,10 @@ mod tests {
10511051

10521052
assert_eq!(1, 1);
10531053
}
1054+
1055+
#[test]
1056+
fn test_invalid_hostaddr_parsing() {
1057+
let s = "user=pass_user dbname=postgres host=host1 hostaddr=127.0.0 port=26257";
1058+
s.parse::<Config>().err().unwrap();
1059+
}
10541060
}

tokio-postgres/src/connect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
// if it's not present, use the value of hostaddr.
5656
let hostname = match host {
5757
Some(Host::Tcp(host)) => host.clone(),
58-
// postgres doesn't support TLS over unix sockets, so the choice here doesn't matter Some()
58+
// postgres doesn't support TLS over unix sockets, so the choice here doesn't matter
5959
#[cfg(unix)]
6060
Some(Host::Unix(_)) => "".to_string(),
6161
None => hostaddr.map_or("".to_string(), |ipaddr| ipaddr.to_string()),

0 commit comments

Comments
 (0)