summaryrefslogtreecommitdiff
path: root/test/sys/test_socket.rs
diff options
context:
space:
mode:
authorYuxuan Shui <yshuiv7@gmail.com>2019-09-04 13:32:26 +0100
committerYuxuan Shui <yshuiv7@gmail.com>2019-09-04 17:06:39 +0100
commit39d158a0142d8a9f38d7952a686cb53fa6542a5f (patch)
treefd75e008f591cd4db249ebb7b4ad57f2c560549b /test/sys/test_socket.rs
parenta4a465d25567f163f9552b977eb4d17435251d41 (diff)
downloadnix-39d158a0142d8a9f38d7952a686cb53fa6542a5f.zip
Fix length of abstract socket address
NULL bytes have no special significance in an abstrace address, and the length of the address is solely decided by the length member. If the length is set to sun_path.len(), all the NULL bytes will be considered part of the address. Tests are updated accordingly. Closes #1119 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Diffstat (limited to 'test/sys/test_socket.rs')
-rw-r--r--test/sys/test_socket.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs
index 7e64d2b7..d4c4738e 100644
--- a/test/sys/test_socket.rs
+++ b/test/sys/test_socket.rs
@@ -106,7 +106,7 @@ pub fn test_addr_equality_abstract() {
assert_eq!(addr1, addr2);
assert_eq!(calculate_hash(&addr1), calculate_hash(&addr2));
- addr2.0.sun_path[18] = 127;
+ addr2.0.sun_path[17] = 127;
assert_ne!(addr1, addr2);
assert_ne!(calculate_hash(&addr1), calculate_hash(&addr2));
}
@@ -117,16 +117,13 @@ pub fn test_addr_equality_abstract() {
pub fn test_abstract_uds_addr() {
let empty = String::new();
let addr = UnixAddr::new_abstract(empty.as_bytes()).unwrap();
- let sun_path = [0u8; 107];
+ let sun_path: [u8; 0] = [];
assert_eq!(addr.as_abstract(), Some(&sun_path[..]));
let name = String::from("nix\0abstract\0test");
let addr = UnixAddr::new_abstract(name.as_bytes()).unwrap();
let sun_path = [
- 110u8, 105, 120, 0, 97, 98, 115, 116, 114, 97, 99, 116, 0, 116, 101, 115, 116, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 110u8, 105, 120, 0, 97, 98, 115, 116, 114, 97, 99, 116, 0, 116, 101, 115, 116
];
assert_eq!(addr.as_abstract(), Some(&sun_path[..]));
assert_eq!(addr.path(), None);