From 6683eb9ab68320bc5fb2820d1d94d666c54d1296 Mon Sep 17 00:00:00 2001 From: Tom Cosgrove Date: Fri, 25 Jun 2004 01:32:55 +0000 Subject: Avoid spurious error message "line too long" (introduced with last commit, which fixed a buffer overflow here). ok weingart@ --- sys/stand/boot/cmd.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'sys/stand') diff --git a/sys/stand/boot/cmd.c b/sys/stand/boot/cmd.c index 44555471267..57712a3853a 100644 --- a/sys/stand/boot/cmd.c +++ b/sys/stand/boot/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.55 2004/06/24 22:32:26 tom Exp $ */ +/* $OpenBSD: cmd.c,v 1.56 2004/06/25 01:32:54 tom Exp $ */ /* * Copyright (c) 1997-1999 Michael Shalayeff @@ -128,9 +128,18 @@ read_conf(void) } while (rc > 0 && *p++ != '\n' && (p-cmd_buf) < sizeof(cmd_buf)); - if (rc < 0) + if (rc < 0) { /* Error from read() */ printf("%s: %s\n", cmd.path, strerror(errno)); - else { + break; + } + + if (rc == 0) { /* eof from read() */ + if (p != cmd_buf) { /* Line w/o trailing \n */ + *p = '\0'; + rc = docmd(); + break; + } + } else { /* rc > 0, read a char */ p--; /* Get back to last character */ if (*p != '\n') { /* Line was too long */ -- cgit v1.2.3