-/* $OpenBSD: deflate.c,v 1.4 2021/07/04 14:24:49 tb Exp $ */
+/* $OpenBSD: deflate.c,v 1.5 2021/07/22 16:40:20 tb Exp $ */
/* deflate.c -- compress data using the deflation algorithm
* Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
status = strm->state->status;
/* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, strm->state->pending_buf);
- TRY_FREE(strm, strm->state->head);
- TRY_FREE(strm, strm->state->prev);
- TRY_FREE(strm, strm->state->window);
+ TRY_FREE(strm, strm->state->pending_buf, strm->state->pending_buf_size);
+ TRY_FREE(strm, strm->state->head, strm->state->hash_size * sizeof(Pos));
+ TRY_FREE(strm, strm->state->prev, strm->state->w_size * sizeof(Pos));
+ TRY_FREE(strm, strm->state->window, strm->state->w_size * 2 * sizeof(Pos));
- ZFREE(strm, strm->state);
+ ZFREE(strm, strm->state, sizeof(deflate_state));
strm->state = Z_NULL;
return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-/* $OpenBSD: infback.c,v 1.7 2021/07/04 14:24:49 tb Exp $ */
+/* $OpenBSD: infback.c,v 1.8 2021/07/22 16:40:20 tb Exp $ */
/* infback.c -- inflate using a call-back interface
* Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
{
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
+ ZFREE(strm, strm->state, sizeof(struct inflate_state));
strm->state = Z_NULL;
Tracev((stderr, "inflate: end\n"));
return Z_OK;
-/* $OpenBSD: inflate.c,v 1.16 2021/07/04 14:24:49 tb Exp $ */
+/* $OpenBSD: inflate.c,v 1.17 2021/07/22 16:40:20 tb Exp $ */
/* inflate.c -- zlib decompression
* Copyright (C) 1995-2016 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
if (windowBits && (windowBits < 8 || windowBits > 15))
return Z_STREAM_ERROR;
if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
- ZFREE(strm, state->window);
+ ZFREE(strm, state->window, 1U << state->wbits);
state->window = Z_NULL;
}
state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits);
if (ret != Z_OK) {
- ZFREE(strm, state);
+ ZFREE(strm, state, sizeof(struct inflate_state));
strm->state = Z_NULL;
}
return ret;
if (inflateStateCheck(strm))
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
+ if (state->window != Z_NULL) ZFREE(strm, state->window, 1U << state->wbits);
+ ZFREE(strm, strm->state, sizeof(struct inflate_state));
strm->state = Z_NULL;
Tracev((stderr, "inflate: end\n"));
return Z_OK;
window = (unsigned char FAR *)
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
if (window == Z_NULL) {
- ZFREE(source, copy);
+ ZFREE(source, copy, sizeof(struct inflate_state));
return Z_MEM_ERROR;
}
}
-/* $OpenBSD: zlib.h,v 1.13 2021/07/04 17:41:23 tb Exp $ */
+/* $OpenBSD: zlib.h,v 1.14 2021/07/22 16:40:20 tb Exp $ */
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.11, January 15th, 2017
*/
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
+typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt size));
struct internal_state;
-/* $OpenBSD: zopenbsd.c,v 1.9 2021/07/04 17:51:20 deraadt Exp $ */
+/* $OpenBSD: zopenbsd.c,v 1.10 2021/07/22 16:40:20 tb Exp $ */
/*
* Copyright (c) 2011 Theo de Raadt <deraadt@openbsd.org>
}
void
-zcfree(void *notused, void *ptr)
+zcfree(void *notused, void *ptr, u_int size)
{
- free(ptr, M_DEVBUF, 0);
+ free(ptr, M_DEVBUF, size);
}
-/* $OpenBSD: zutil.h,v 1.21 2021/07/08 20:02:42 deraadt Exp $ */
+/* $OpenBSD: zutil.h,v 1.22 2021/07/22 16:40:20 tb Exp $ */
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
#ifndef Z_SOLO
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
unsigned size));
- void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
+ void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr, unsigned size));
#endif
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
+#define ZFREE(strm, addr, size) \
+ (*((strm)->zfree))((strm)->opaque, (voidpf)(addr), (size))
+#define TRY_FREE(s, p, size) ZFREE(s, p, size)
/* Reverse the bytes in a 32-bit value */
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
-/* $OpenBSD: ppp-deflate.c,v 1.16 2021/03/05 09:21:08 jsg Exp $ */
+/* $OpenBSD: ppp-deflate.c,v 1.17 2021/07/22 16:40:19 tb Exp $ */
/* $NetBSD: ppp-deflate.c,v 1.1 1996/03/15 02:28:09 paulus Exp $ */
/*
#define DEFLATE_OVHD 2 /* Deflate overhead/packet */
static void *zcalloc(void *, u_int items, u_int size);
-static void zcfree(void *, void *ptr);
+static void zcfree(void *, void *ptr, u_int size);
static void *z_comp_alloc(u_char *options, int opt_len);
static void *z_decomp_alloc(u_char *options, int opt_len);
static void z_comp_free(void *state);
}
void
-zcfree(void *notused, void *ptr)
+zcfree(void *notused, void *ptr, u_int size)
{
- free(ptr, M_DEVBUF, 0);
+ free(ptr, M_DEVBUF, size);
}
/*