Date: Mon, 14 Feb 2022 19:47:41 GMT From: Justin Hibbits <jhibbits@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 2053dee56a9f - stable/13 - Fix gzip compressed core dumps on big endian architectures Message-ID: <202202141947.21EJlf58035895@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=2053dee56a9f5b2ad9286def352c4e198f39dfb1 commit 2053dee56a9f5b2ad9286def352c4e198f39dfb1 Author: Justin Hibbits <jhibbits@FreeBSD.org> AuthorDate: 2022-02-10 15:21:36 +0000 Commit: Justin Hibbits <jhibbits@FreeBSD.org> CommitDate: 2022-02-14 19:30:52 +0000 Fix gzip compressed core dumps on big endian architectures The gzip trailer words (size and CRC) are both little-endian per the spec. MFC after: 3 days Sponsored by: Juniper Networks, Inc. (cherry picked from commit 6db44b0158c37f2206f2c4ea7f29f5b774389e54) --- sys/kern/subr_compressor.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/subr_compressor.c b/sys/kern/subr_compressor.c index b202d271cfa3..74526a949437 100644 --- a/sys/kern/subr_compressor.c +++ b/sys/kern/subr_compressor.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include <sys/systm.h> #include <sys/compressor.h> +#include <sys/endian.h> #include <sys/kernel.h> #include <sys/linker_set.h> #include <sys/malloc.h> @@ -201,9 +202,9 @@ gz_write(void *stream, void *data, size_t len, compressor_cb_t cb, * Try to pack as much of the trailer into the * output buffer as we can. */ - ((uint32_t *)trailer)[0] = s->gz_crc; + ((uint32_t *)trailer)[0] = htole32(s->gz_crc); ((uint32_t *)trailer)[1] = - s->gz_stream.total_in; + htole32(s->gz_stream.total_in); room = MIN(sizeof(trailer), s->gz_bufsz - len); memcpy(s->gz_buffer + len, trailer, room);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202202141947.21EJlf58035895>