summaryrefslogtreecommitdiff
path: root/lib/libz/gzio.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-07-06 00:11:41 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-07-06 00:11:41 +0000
commit84f0420e672cc5b2cdfee933c42ffce105bed7c2 (patch)
tree8fae1e3ec3360997d63b7947a044749a71e1ec79 /lib/libz/gzio.c
parentf92e5c37316fc6b59bb3937e0576a610809ae567 (diff)
Add some missing checks for malloc() returning NULL.
Noticed by Lars J. Buitinck. deraadt@ OK
Diffstat (limited to 'lib/libz/gzio.c')
-rw-r--r--lib/libz/gzio.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libz/gzio.c b/lib/libz/gzio.c
index 3acfd333353..4ad89681f55 100644
--- a/lib/libz/gzio.c
+++ b/lib/libz/gzio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gzio.c,v 1.7 2002/03/12 00:25:57 millert Exp $ */
+/* $OpenBSD: gzio.c,v 1.8 2002/07/06 00:11:40 millert Exp $ */
/* gzio.c -- IO on .gz files
* Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
@@ -681,6 +681,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
/* At this point, offset is the number of zero bytes to write. */
if (s->inbuf == Z_NULL) {
s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
+ if (s->inbuf == Z_NULL) return -1L;
zmemzero(s->inbuf, Z_BUFSIZE);
}
while (offset > 0) {
@@ -723,6 +724,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
if (offset != 0 && s->outbuf == Z_NULL) {
s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
+ if (s->outbuf == Z_NULL) return -1L;
}
while (offset > 0) {
int size = Z_BUFSIZE;
@@ -862,12 +864,13 @@ const char* ZEXPORT gzerror (file, errnum)
*errnum = s->z_err;
if (*errnum == Z_OK) return (const char*)"";
- m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
+ m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
TRYFREE(s->msg);
s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
+ if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
strcpy(s->msg, s->path);
strcat(s->msg, ": ");
strcat(s->msg, m);