У меня так часто валится apt-pipe что я решил сделать профилактический
проход по apt'у - понятное дело отфильтровывая его многочисленные
неисправимые преимущества.

Часть из этих багов тривиально можно пофиксить в коде, например,
переставить местами проверку на пустоту строки и работу с ней (работать-то
и так будет, но порядок стоит сделать более естественным).

sourcelist.cc,indexfile.cc

+++++++++++ sourcelist.cc, indexfile.cc, pkgsystem.cc 

// Global list of Items supported          
static  pkgSourceList::Type *ItmList[10];
pkgSourceList::Type **pkgSourceList::Type::GlobalList = ItmList;
unsigned long pkgSourceList::Type::GlobalListLen = 0;
                              
// Type::Type - Constructor                                             /*{{{*/
// ---------------------------------------------------------------------
/* Link this to the global list of items*/
pkgSourceList::Type::Type()
{
   ItmList[GlobalListLen] = this;
   GlobalListLen++;
}

// Type::GetType - Get a specific meta for a given type                 /*{{{*/
// ---------------------------------------------------------------------
/* */
pkgSourceList::Type *pkgSourceList::Type::GetType(const char *Type)
{
   for (unsigned I = 0; I != GlobalListLen; I++)
      if (strcmp(GlobalList[I]->Name,Type) == 0)
         return GlobalList[I];
   return 0;
}

+++++++++++

Проверки на исчерпание GlobalListLen ес-но нет. Type - это тип урла 
(cdrom,file,etc), пока их
количество < 10, поэтому и не падает ;)



+++++++++++ sourceslist.cc

    string FingerPrint = Block.Find("Fingerprint");

      // CNC:2002-08-15
      char *buffer = new char[FingerPrint.length()+1];
      char *p = buffer;;
      for (string::const_iterator I = FingerPrint.begin();
           I != FingerPrint.end(); I++)
      {
         if (*I != ' ' && *I != '\t')
            *p++ = *I;
      }
      *p = 0;
      Vendor->FingerPrint.push_back(string(buffer));
      delete [] buffer;

      if (Vendor->FingerPrint.size() == 0 ||
          Vendor->Description.empty() == true)
      {
         _error->Error(_("Vendor block %s is invalid"), 
Vendor->VendorID.c_str());
         delete Vendor;
         continue;
      }

+++++++++++

Промолчим в тряпочку про buffer, но проверку на пустоту можно было бы:
1. сделать до а не после
2. всё-таки воспользоваться везде empty(), можно даже и с  == true ;)

+++++++++++ sourceslist.cc

// CNC:2003-12-10 - 300 is too short.
char Buffer[1024];

+++++++++++
Это по-моему надо в фортунки ;)

+++++++++++ contrib/fileutl.cc

string flNotDir(string File)
{
   string::size_type Res = File.rfind('/');
   if (Res == string::npos)
      return File;
   Res++;
   return string(File,Res,Res - File.length());
}


string flExtension(string File)
{
   string::size_type Res = File.rfind('.');
   if (Res == string::npos)
      return File;
   Res++;
   return string(File,Res,Res - File.length());
}

++++++++++
Ещё одно подтверждение уникальности авторов,
по идее надо делать подстроку от res, до string::npos, 
у них получается вторым числом отрицательное число - которое подходит на эту 
роль ;)

+++++++++++ contrib/strurl.cc
int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd)
int stringcmp(string::const_iterator A,string::const_iterator AEnd, const char 
*B,const char *BEnd)
int stringcmp(string::const_iterator A,string::const_iterator AEnd,
              string::const_iterator B,string::const_iterator BEnd)
...
int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd)
int stringcasecmp(string::const_iterator A,string::const_iterator AEnd,const 
char *B,const char *BEnd)
int stringcasecmp(string::const_iterator A,string::const_iterator AEnd,
                  string::const_iterator B,string::const_iterator BEnd)
....

+++++++++++ там же
наверное всё-таки стоит перейти уже на шаблоны ;)

+++++++++++
Стихи от apt:
// Process is dead, this is kind of bad..
+++++++++++
В фортунки однозначно ;)

+++++++++++ там же
bool ParseQuoteWord(const char *&String,string &Res)
...
   char Buffer[1024];
   char Tmp[3];
   const char *Start = String;
   char *I;
   for (I = Buffer; I < Buffer + sizeof(Buffer) && Start != C; I++)
   {
...
++++++++++++
Ну ладно уникальный заголовок, но размер Buffer в данном случае уж точно 
подобрать можно было.

++++++++++++ там же
// strtabexpand - Converts tabs into 8 spaces                           /*{{{*/
// ---------------------------------------------------------------------
/* */
char *_strtabexpand(char *String,size_t Len)
{
....
memmove(I + Len,I + 1,strlen(I) + 1);
.....
+++++++++++++
Из разряда: создаём трудности, а потом мужественно их преодолеваем. Не везде 
размер буфера увеличили до 1024 ;)
(в contrib/configuration.cc он до сих пор те самые пресловутые 300 единиц).


+++++++++++++ там же
// strstrip - Remove white space from the front and back of a string    /*{{{*/
// ---------------------------------------------------------------------
/* This is handy to use when parsing a file. It also removes \n's left  
   over from fgets and company */
char *_strstrip(char *String)
{
....
++++++++++++++
Из той же оперы, в configuration.cc вызов такой: "_strstrip(Buffer);", соотв. 
вся великая работа по удалению впереди идущих пробелов исчезает (или тщательно 
повторяется в другом месте - тут и такое бывает тоже)





_______________________________________________
Devel-conf mailing list
[email protected]
https://lists.altlinux.org/mailman/listinfo/devel-conf

Ответить