Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libterminfo Ensure that we request a buffer big enough, ...
details: https://anonhg.NetBSD.org/src/rev/e54aeb23926a
branches: trunk
changeset: 779549:e54aeb23926a
user: roy <roy%NetBSD.org@localhost>
date: Sat Jun 02 19:10:33 2012 +0000
description:
Ensure that we request a buffer big enough, although with the current
terminfo specification this should never happen.
Correctly return NULL when realloc(3) fails.
diffstat:
lib/libterminfo/tparm.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diffs (32 lines):
diff -r 5460fd37346b -r e54aeb23926a lib/libterminfo/tparm.c
--- a/lib/libterminfo/tparm.c Sat Jun 02 18:32:27 2012 +0000
+++ b/lib/libterminfo/tparm.c Sat Jun 02 19:10:33 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tparm.c,v 1.7 2011/10/03 20:13:48 roy Exp $ */
+/* $NetBSD: tparm.c,v 1.8 2012/06/02 19:10:33 roy Exp $ */
/*
* Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,8 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tparm.c,v 1.7 2011/10/03 20:13:48 roy Exp $");
+__RCSID("$NetBSD: tparm.c,v 1.8 2012/06/02 19:10:33 roy Exp $");
+#include <sys/param.h>
#include <assert.h>
#include <ctype.h>
@@ -91,10 +92,10 @@
char *buf;
if (term->_bufpos + len >= term->_buflen) {
- len = term->_buflen + BUFSIZ;
+ len = term->_buflen + MAX(len, BUFSIZ);
buf = realloc(term->_buf, len);
if (buf == NULL)
- return 0;
+ return NULL;
term->_buf = buf;
term->_buflen = len;
}
Home |
Main Index |
Thread Index |
Old Index