summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-04 04:22:49 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2002-07-04 04:22:49 +0000
commit14df51898fb77d30235fa80d84b66f49925f4bb2 (patch)
tree1d08b18caa73b563017a1094e989d68f3aaa0a85
parente8072b366f5ecdf3ab9a030a80664186605c4911 (diff)
4 unchecked mallocs; cloder@acm.org
-rw-r--r--usr.bin/patch/inp.c6
-rw-r--r--usr.bin/patch/patch.c12
2 files changed, 14 insertions, 4 deletions
diff --git a/usr.bin/patch/inp.c b/usr.bin/patch/inp.c
index f27866571d2..a60d48aa138 100644
--- a/usr.bin/patch/inp.c
+++ b/usr.bin/patch/inp.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: inp.c,v 1.8 1999/01/03 05:33:48 millert Exp $ */
+/* $OpenBSD: inp.c,v 1.9 2002/07/04 04:22:48 deraadt Exp $ */
#ifndef lint
-static char rcsid[] = "$OpenBSD: inp.c,v 1.8 1999/01/03 05:33:48 millert Exp $";
+static char rcsid[] = "$OpenBSD: inp.c,v 1.9 2002/07/04 04:22:48 deraadt Exp $";
#endif /* not lint */
#include "EXTERN.h"
@@ -288,6 +288,8 @@ char *filename;
lines_per_buf = BUFFERSIZE / maxlen;
tireclen = maxlen;
tibuf[0] = malloc((MEM)(BUFFERSIZE + 1));
+ if (tibuf[0] == Nullch)
+ fatal1("out of memory\n");
tibuf[1] = malloc((MEM)(BUFFERSIZE + 1));
if (tibuf[1] == Nullch)
fatal1("out of memory\n");
diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c
index 75a33895a86..fa71846c91c 100644
--- a/usr.bin/patch/patch.c
+++ b/usr.bin/patch/patch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: patch.c,v 1.14 2002/03/05 08:56:55 niklas Exp $ */
+/* $OpenBSD: patch.c,v 1.15 2002/07/04 04:22:48 deraadt Exp $ */
/* patch - a program to apply diffs to original files
*
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: patch.c,v 1.14 2002/03/05 08:56:55 niklas Exp $";
+static char rcsid[] = "$OpenBSD: patch.c,v 1.15 2002/07/04 04:22:48 deraadt Exp $";
#endif /* not lint */
#include "INTERN.h"
@@ -105,6 +105,8 @@ char **argv;
tmpname_len = strlen (tmpdir) + 20;
TMPOUTNAME = (char *) malloc (tmpname_len);
+ if (TMPOUTNAME == NULL)
+ fatal1("cannot allocate memory");
strcpy (TMPOUTNAME, tmpdir);
strcat (TMPOUTNAME, "/patchoXXXXXX");
if ((i = mkstemp(TMPOUTNAME)) < 0)
@@ -112,6 +114,8 @@ char **argv;
Close(i);
TMPINNAME = (char *) malloc (tmpname_len);
+ if (TMPINNAME == NULL)
+ fatal1("cannot allocate memory");
strcpy (TMPINNAME, tmpdir);
strcat (TMPINNAME, "/patchiXXXXXX");
if ((i = mkstemp(TMPINNAME)) < 0)
@@ -119,6 +123,8 @@ char **argv;
Close(i);
TMPREJNAME = (char *) malloc (tmpname_len);
+ if (TMPREJNAME == NULL)
+ fatal1("cannot allocate memory");
strcpy (TMPREJNAME, tmpdir);
strcat (TMPREJNAME, "/patchrXXXXXX");
if ((i = mkstemp(TMPREJNAME)) < 0)
@@ -126,6 +132,8 @@ char **argv;
Close(i);
TMPPATNAME = (char *) malloc (tmpname_len);
+ if (TMPPATNAME == NULL)
+ fatal1("cannot allocate memory");
strcpy (TMPPATNAME, tmpdir);
strcat (TMPPATNAME, "/patchpXXXXXX");
if ((i = mkstemp(TMPPATNAME)) < 0)