tag 493382 confirmed thanks Hello, thanks very much for your report. You patch is good, though in other places in the code a buffer is used and an error is raised whenever the line is too much long. I attach the new patch, but I haven't tested it yet. I used the 500 length, since the previous code used to divide 1024 by 2. Well, the worse problem is that sizeof(Buffer) is 4 (or 8) not 1024. > it managed to leak out a megabyte of memory in no time, gods only know why I'm not god but for each configuration line 1024 bytes are lost ;) -- http://syx.googlecode.com - Smalltalk YX http://lethalman.blogspot.com - Thoughts about computer technologies http://www.debian.org - The Universal Operating System
=== modified file 'apt-pkg/contrib/configuration.cc' --- apt-pkg/contrib/configuration.cc 2008-04-02 03:55:09 +0000 +++ apt-pkg/contrib/configuration.cc 2008-10-04 15:42:44 +0000 @@ -505,6 +505,7 @@ int CurLine = 0; bool InComment = false; + char Buffer[500]; while (F.eof() == false) { // The raw input line. @@ -513,16 +514,12 @@ std::string Fragment; // Grab the next line of F and place it in Input. - do - { - char *Buffer = new char[1024]; - - F.clear(); - F.getline(Buffer,sizeof(Buffer) / 2); - - Input += Buffer; - } - while (F.fail() && !F.eof()); + F.clear(); + F.getline(Buffer,sizeof(Buffer)); + if (F.fail() && !F.feof()) + return _error->Error(_("Line %u too long in source list %s."), + CurLine,FName.c_str()); + Input += Buffer; // Expand tabs in the input line and remove leading and trailing // whitespace.
Attachment:
signature.asc
Description: Digital signature