From 46cb75a25840d793e4f7db2b1c7e702fbbfe87df Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 31 Jul 2012 12:22:37 +1000 Subject: [PATCH] - dtucker@cvs.openbsd.org 2012/07/13 01:35:21 [servconf.c] handle long comments in config files better. bz#2025, ok markus --- ChangeLog | 3 +++ servconf.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9104217ad..2dafce311 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,9 @@ by shipping a config that overrides the current UsePrivilegeSeparation=yes default. Make it easier to flip the default in the future by adding too. prodded markus@ feedback dtucker@ "get it in" deraadt@ + - dtucker@cvs.openbsd.org 2012/07/13 01:35:21 + [servconf.c] + handle long comments in config files better. bz#2025, ok markus 20120720 - (dtucker) Import regened moduli file. diff --git a/servconf.c b/servconf.c index 427bdeef1..ee2e531a0 100644 --- a/servconf.c +++ b/servconf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: servconf.c,v 1.228 2012/07/10 02:19:15 djm Exp $ */ +/* $OpenBSD: servconf.c,v 1.229 2012/07/13 01:35:21 dtucker Exp $ */ /* * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland * All rights reserved @@ -1526,8 +1526,9 @@ process_server_config_line(ServerOptions *options, char *line, void load_server_config(const char *filename, Buffer *conf) { - char line[1024], *cp; + char line[4096], *cp; FILE *f; + int lineno = 0; debug2("%s: filename %s", __func__, filename); if ((f = fopen(filename, "r")) == NULL) { @@ -1536,6 +1537,9 @@ load_server_config(const char *filename, Buffer *conf) } buffer_clear(conf); while (fgets(line, sizeof(line), f)) { + lineno++; + if (strlen(line) == sizeof(line) - 1) + fatal("%s line %d too long", filename, lineno); /* * Trim out comments and strip whitespace * NB - preserve newlines, they are needed to reproduce