File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
28
28
- Fixed a bug in nix::unistd that would result in an infinite loop
29
29
when a group or user lookup required a buffer larger than
30
30
16KB. (#[ 1198] ( https://github.com/nix-rust/nix/pull/1198 ) )
31
+ - Fixed unaligned casting of ` cmsg_data ` to ` af_alg_iv ` (#[ 1206] ( https://github.com/nix-rust/nix/pull/1206 ) )
31
32
32
33
### Removed
33
34
Original file line number Diff line number Diff line change @@ -657,15 +657,26 @@ impl<'a> ControlMessage<'a> {
657
657
}
658
658
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
659
659
ControlMessage :: AlgSetIv ( iv) => {
660
+ let af_alg_iv = libc:: af_alg_iv {
661
+ ivlen : iv. len ( ) as u32 ,
662
+ iv : [ 0u8 ; 0 ] ,
663
+ } ;
664
+
665
+ let size = mem:: size_of :: < libc:: af_alg_iv > ( ) ;
666
+
660
667
unsafe {
661
- let alg_iv = cmsg_data as * mut libc:: af_alg_iv ;
662
- ( * alg_iv) . ivlen = iv. len ( ) as u32 ;
668
+ ptr:: copy_nonoverlapping (
669
+ & af_alg_iv as * const _ as * const u8 ,
670
+ cmsg_data,
671
+ size,
672
+ ) ;
663
673
ptr:: copy_nonoverlapping (
664
674
iv. as_ptr ( ) ,
665
- ( * alg_iv ) . iv . as_mut_ptr ( ) ,
675
+ cmsg_data . add ( size ) ,
666
676
iv. len ( )
667
677
) ;
668
678
} ;
679
+
669
680
return
670
681
} ,
671
682
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
You can’t perform that action at this time.
0 commit comments