diff options
author | Tom Cosgrove <tom@cvs.openbsd.org> | 2004-06-25 01:32:55 +0000 |
---|---|---|
committer | Tom Cosgrove <tom@cvs.openbsd.org> | 2004-06-25 01:32:55 +0000 |
commit | 6683eb9ab68320bc5fb2820d1d94d666c54d1296 (patch) | |
tree | b976cdc511f90fc9a55c5852a1de11e3f86faa16 /sys/stand/boot | |
parent | b33b57311177d6c88770ae91701cc29b5773172f (diff) |
Avoid spurious error message "line too long" (introduced with last commit,
which fixed a buffer overflow here).
ok weingart@
Diffstat (limited to 'sys/stand/boot')
-rw-r--r-- | sys/stand/boot/cmd.c | 15 |
1 files changed, 12 insertions, 3 deletions
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 */ |