diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-08 20:05:44 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-08 20:05:44 +0000 |
commit | e487d84e03615256aca61431bb9b515db8c2b6e6 (patch) | |
tree | 9a7d666929fd7fc13f7c3a0ead59d88c7de24396 /cli.c | |
parent | 253effb61d3f7917549ee859fa93c9e4a1f15ede (diff) |
- markus@cvs.openbsd.org 2001/05/06 21:23:31
[cli.c]
cli_read() fails to catch SIGINT + overflow; from obdb@zzlevo.net
Diffstat (limited to 'cli.c')
-rw-r--r-- | cli.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: cli.c,v 1.12 2001/05/06 17:52:07 mouring Exp $ */ +/* $OpenBSD: cli.c,v 1.13 2001/05/06 21:23:31 markus Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. @@ -25,7 +25,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: cli.c,v 1.12 2001/05/06 17:52:07 mouring Exp $"); +RCSID("$OpenBSD: cli.c,v 1.13 2001/05/06 21:23:31 markus Exp $"); #include "xmalloc.h" #include "log.h" @@ -141,15 +141,19 @@ cli_read(char* buf, int size, int echo) while (ch != '\n') { n = read(cli_input, &ch, 1); + if (intr) + break; if (n == -1 && (errno == EAGAIN || errno == EINTR)) continue; if (n != 1) break; - if (ch == '\n' || intr != 0) + if (ch == '\n') break; - if (i < size) + if (i < size - 1) buf[i++] = ch; } + if (intr) + i = 0; buf[i] = '\0'; if (!echo) |