summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed/compile.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2010-11-15 20:26:00 +0000
committermillert <millert@openbsd.org>2010-11-15 20:26:00 +0000
commit1d6c41582292a2546d2ba51324f41fb984264a0c (patch)
tree8203ffd5aca9fbfb51ae8db9858f8e88f6903d40 /usr.bin/sed/compile.c
parentAesthetic improvements to make it appear more normal and knf'y. (diff)
downloadwireguard-openbsd-1d6c41582292a2546d2ba51324f41fb984264a0c.tar.xz
wireguard-openbsd-1d6c41582292a2546d2ba51324f41fb984264a0c.zip
NUL-terminate buffer in compiler_text() after realloc, not before.
Now that we have dynamically sized buffers there may not be room for the NUL until after realloc.
Diffstat (limited to 'usr.bin/sed/compile.c')
-rw-r--r--usr.bin/sed/compile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/sed/compile.c b/usr.bin/sed/compile.c
index aa8ee56dca4..012701d9064 100644
--- a/usr.bin/sed/compile.c
+++ b/usr.bin/sed/compile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compile.c,v 1.33 2010/07/01 17:04:24 naddy Exp $ */
+/* $OpenBSD: compile.c,v 1.34 2010/11/15 20:26:00 millert Exp $ */
/*-
* Copyright (c) 1992 Diomidis Spinellis.
@@ -685,8 +685,9 @@ compile_text(void)
}
}
free(lbuf);
+ text = xrealloc(text, size + 1);
text[size] = '\0';
- return (xrealloc(text, size + 1));
+ return (text);
}
/*