@@ -688,6 +688,62 @@ fn download_static_lib_binaries() {
688688 download_file ( & url, & static_lib_path ( ) ) ;
689689}
690690
691+ /// Skip the gzip header without validating CRC.
692+ /// This avoids depending on crc32fast which uses hardware CRC intrinsics
693+ /// that aren't supported by all rustc backends (e.g., cranelift on aarch64).
694+ fn skip_gzip_header < R : Read > ( input : & mut R ) -> io:: Result < ( ) > {
695+ let mut header = [ 0u8 ; 10 ] ;
696+ input. read_exact ( & mut header) ?;
697+
698+ // Validate magic bytes (0x1f 0x8b) and compression method (8 = deflate)
699+ if header[ 0 ] != 0x1f || header[ 1 ] != 0x8b {
700+ return Err ( io:: Error :: other ( "Invalid gzip magic" ) ) ;
701+ }
702+ if header[ 2 ] != 8 {
703+ return Err ( io:: Error :: other ( "Unsupported compression method" ) ) ;
704+ }
705+
706+ let flags = header[ 3 ] ;
707+
708+ // FEXTRA - extra field
709+ if flags & 0x04 != 0 {
710+ let mut len = [ 0u8 ; 2 ] ;
711+ input. read_exact ( & mut len) ?;
712+ let extra_len = u16:: from_le_bytes ( len) as u64 ;
713+ io:: copy ( & mut input. by_ref ( ) . take ( extra_len) , & mut io:: sink ( ) ) ?;
714+ }
715+
716+ // FNAME - original filename, null-terminated
717+ if flags & 0x08 != 0 {
718+ let mut byte = [ 0u8 ; 1 ] ;
719+ loop {
720+ input. read_exact ( & mut byte) ?;
721+ if byte[ 0 ] == 0 {
722+ break ;
723+ }
724+ }
725+ }
726+
727+ // FCOMMENT - comment, null-terminated
728+ if flags & 0x10 != 0 {
729+ let mut byte = [ 0u8 ; 1 ] ;
730+ loop {
731+ input. read_exact ( & mut byte) ?;
732+ if byte[ 0 ] == 0 {
733+ break ;
734+ }
735+ }
736+ }
737+
738+ // FHCRC - header CRC16 (skip without validating)
739+ if flags & 0x02 != 0 {
740+ let mut crc = [ 0u8 ; 2 ] ;
741+ input. read_exact ( & mut crc) ?;
742+ }
743+
744+ Ok ( ( ) )
745+ }
746+
691747fn decompress_to_writer < R , W > ( input : & mut R , output : & mut W ) -> io:: Result < ( ) >
692748where
693749 R : Read ,
@@ -699,7 +755,7 @@ where
699755 let mut input_offset = 0 ;
700756
701757 // Skip the gzip header
702- gzip_header :: read_gz_header ( input) ?;
758+ skip_gzip_header ( input) ?;
703759
704760 loop {
705761 let bytes_read = input. read ( & mut input_buffer[ input_offset..] ) ?;
0 commit comments