Date: Thu, 9 Aug 2018 02:55:48 +0000 (UTC) From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337523 - head/stand/libsa Message-ID: <201808090255.w792tm4j098816@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kevans Date: Thu Aug 9 02:55:48 2018 New Revision: 337523 URL: https://svnweb.freebsd.org/changeset/base/337523 Log: libsa: exit on EOF in ngets It was possible in some rare circumstances for ngets to behave terribly with bhyveload and some form of redirecting user input over a pipe. PR: 198706 Submitted by: Ivan Krivonos <int0dster@gmail.com> MFC after: 1 week Modified: head/stand/libsa/gets.c Modified: head/stand/libsa/gets.c ============================================================================== --- head/stand/libsa/gets.c Thu Aug 9 02:47:22 2018 (r337522) +++ head/stand/libsa/gets.c Thu Aug 9 02:55:48 2018 (r337523) @@ -44,8 +44,11 @@ ngets(char *buf, int n) int c; char *lp; - for (lp = buf;;) - switch (c = getchar() & 0177) { + for (lp = buf;;) { + c = getchar(); + if (c == -1) + break; + switch (c & 0177) { case '\n': case '\r': *lp = '\0'; @@ -79,6 +82,7 @@ ngets(char *buf, int n) putchar(c); } } + } /*NOTREACHED*/ }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808090255.w792tm4j098816>