diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-09-04 16:35:56 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-04 16:35:56 +0000 |
commit | 16624668d40cb3f8545188d95f96d635313d5479 (patch) | |
tree | a1e6151e093515698c7c6463016421bd097a1dc1 /test/sys | |
parent | 01f4d57eede3ed2f1051778113b1d6a7dff8e9d6 (diff) | |
parent | 39d158a0142d8a9f38d7952a686cb53fa6542a5f (diff) | |
download | nix-16624668d40cb3f8545188d95f96d635313d5479.zip |
Merge #1120
1120: Fix length of abstract socket address r=asomers a=yshui
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>
Co-authored-by: Yuxuan Shui <yshuiv7@gmail.com>
Diffstat (limited to 'test/sys')
-rw-r--r-- | test/sys/test_socket.rs | 9 |
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); |