diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-27 19:29:46 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-27 19:29:46 +0000 |
commit | 196daed3e0a5dd6ef886c34280f210771265aa64 (patch) | |
tree | d031e4883c9bd9cecd81314fc20b3f1ccc39cb64 /usr.bin/compress | |
parent | d86da5bd6abde93d50f7b724a52771877c8cabbc (diff) |
Fix bug in put_int32() on big endian cpus; deraadt@ OK
Diffstat (limited to 'usr.bin/compress')
-rw-r--r-- | usr.bin/compress/gzopen.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/usr.bin/compress/gzopen.c b/usr.bin/compress/gzopen.c index 663a8306cdc..38cf82c19d8 100644 --- a/usr.bin/compress/gzopen.c +++ b/usr.bin/compress/gzopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gzopen.c,v 1.7 2003/06/22 15:22:43 deraadt Exp $ */ +/* $OpenBSD: gzopen.c,v 1.8 2003/06/27 19:29:45 millert Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -59,7 +59,7 @@ */ const char gz_rcsid[] = - "$OpenBSD: gzopen.c,v 1.7 2003/06/22 15:22:43 deraadt Exp $"; + "$OpenBSD: gzopen.c,v 1.8 2003/06/27 19:29:45 millert Exp $"; #include <sys/types.h> #include <sys/stat.h> @@ -252,16 +252,9 @@ gz_flush(void *cookie, int flush) static int put_int32(gz_stream *s, u_int32_t x) { - if (write(s->z_fd, &x, 1) != 1) - return Z_ERRNO; - x >>= 8; - if (write(s->z_fd, &x, 1) != 1) - return Z_ERRNO; - x >>= 8; - if (write(s->z_fd, &x, 1) != 1) - return Z_ERRNO; - x >>= 8; - if (write(s->z_fd, &x, 1) != 1) + u_int32_t y = htole32(x); + + if (write(s->z_fd, &y, sizeof(y)) != sizeof(y)) return Z_ERRNO; return 0; } |