From 5e14c452578c536077a994e3a3c1cc4829ba6637 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 17:06:30 +0000 Subject: [PATCH] * Increase length of line buffer in ReadConfigFile to 1... Author: mdz Date: 2004-04-30 04:00:15 GMT * Increase length of line buffer in ReadConfigFile to 1024 chars; detect if a line is longer than that and error out (Closes: #244835) --- apt-pkg/contrib/configuration.cc | 8 ++++++-- debian/changelog | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index e6ea2a0ef..740aa8137 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: configuration.cc,v 1.27 2003/07/26 00:27:36 mdz Exp $ +// $Id: configuration.cc,v 1.28 2004/04/30 04:00:15 mdz Exp $ /* ###################################################################### Configuration Class @@ -452,7 +452,7 @@ bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional, if (!F != 0) return _error->Errno("ifstream::ifstream",_("Opening configuration file %s"),FName.c_str()); - char Buffer[300]; + char Buffer[1024]; string LineBuffer; string Stack[100]; unsigned int StackPos = 0; @@ -466,6 +466,10 @@ bool ReadConfigFile(Configuration &Conf,string FName,bool AsSectional, { F.getline(Buffer,sizeof(Buffer)); CurLine++; + // This should be made to work instead, but this is better than looping + if (F.fail() && !F.eof()) + return _error->Error(_("Line %d too long (max %d)"), CurLine, sizeof(Buffer)); + _strtabexpand(Buffer,sizeof(Buffer)); _strstrip(Buffer); diff --git a/debian/changelog b/debian/changelog index f67395bd2..bd158a834 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,8 +28,11 @@ apt (0.5.25) unstable; urgency=low (Closes: #246550) * Support DEB_BUILD_OPTIONS=noopt in debian/rules (Closes: #244293) + * Increase length of line buffer in ReadConfigFile to 1024 chars; + detect if a line is longer than that and error out + (Closes: #244835) - -- Matt Zimmerman Thu, 29 Apr 2004 20:46:35 -0700 + -- Matt Zimmerman Thu, 29 Apr 2004 21:00:02 -0700 apt (0.5.24) unstable; urgency=low -- 2.45.2