summaryrefslogtreecommitdiff
path: root/distrib
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2013-11-27 20:25:48 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2013-11-27 20:25:48 +0000
commit791aa4b8eef5b21ba07f7b8c6ad2437f942ecc08 (patch)
tree8ca96b09313a25fe5a7e73f84af60539acdf55ac /distrib
parent30e400fa62bb39e602c02946b29b0ac798ae7129 (diff)
astoundingly, the read loop has been subtly broken in a variety of ways
on big-endian machines for quite a while. Some discussion with millert and guenther to repair it.
Diffstat (limited to 'distrib')
-rw-r--r--distrib/special/more/more.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/distrib/special/more/more.c b/distrib/special/more/more.c
index 7b2453d18d4..ba972431b6d 100644
--- a/distrib/special/more/more.c
+++ b/distrib/special/more/more.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: more.c,v 1.33 2013/11/26 21:13:04 deraadt Exp $ */
+/* $OpenBSD: more.c,v 1.34 2013/11/27 20:25:47 deraadt Exp $ */
/*
* Copyright (c) 2003 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -1610,23 +1610,25 @@ handle_signal(void)
int
readch(void)
{
- int ch;
+ unsigned char ch;
+ int r;
- errno = 0;
/* We know stderr is hooked up to /dev/tty so this is safe. */
again:
- if (read(STDERR_FILENO, &ch, 1) <= 0) {
- if (signo != 0) {
- if ((ch = handle_signal()) == -1)
- goto again;
- } else {
- if (errno != EINTR)
- end_it();
- else
- ch = otty.c_cc[VKILL];
- }
+ switch (read(STDERR_FILENO, &ch, 1)) {
+ case 1:
+ return (ch);
+ case -1:
+ if (errno != EINTR)
+ end_it();
+
+ r = handle_signal();
+ if (r == -1)
+ goto again;
+ return (r); /* redraw, continue, etc */
+ case 0:
+ end_it();
}
- return (ch);
}
static char BS1 = '\b';