Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libedit Test early for EOF to avoid infinite loop in the...
details: https://anonhg.NetBSD.org/src/rev/c8ce2bd8a43c
branches: trunk
changeset: 786984:c8ce2bd8a43c
user: christos <christos%NetBSD.org@localhost>
date: Mon May 27 23:55:55 2013 +0000
description:
Test early for EOF to avoid infinite loop in the wide char case. From
Linas Vepstas: linasvepstas at gmail dot com
diffstat:
lib/libedit/read.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diffs (32 lines):
diff -r b7c860df8346 -r c8ce2bd8a43c lib/libedit/read.c
--- a/lib/libedit/read.c Mon May 27 23:15:51 2013 +0000
+++ b/lib/libedit/read.c Mon May 27 23:55:55 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.69 2012/09/11 12:31:08 christos Exp $ */
+/* $NetBSD: read.c,v 1.70 2013/05/27 23:55:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.69 2012/09/11 12:31:08 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.70 2013/05/27 23:55:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -341,6 +341,13 @@
}
}
+ /* Test for EOF */
+ if (num_read == 0) {
+ errno = 0;
+ *cp = '\0';
+ return 0;
+ }
+
#ifdef WIDECHAR
if (el->el_flags & CHARSET_IS_UTF8) {
if (!utf8_islead((unsigned char)cbuf[0]))
Home |
Main Index |
Thread Index |
Old Index