Репозитории ALT
S: | 0.5.15lorg2-alt86 |
5.1: | 0.5.15lorg2-alt33.M50P.1 |
4.1: | 0.5.15lorg2-alt20.M41.1 |
4.0: | 0.5.15lorg2-alt18.M40.1 |
+updates: | 0.5.15lorg2-alt18 |
3.0: | 0.5.15cnc6-alt16 |
Группа :: Система/Настройка/Пакеты
Пакет: apt
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: apt-0.5.15lorg2-alt-realloc.patch
Скачать
Скачать
diff -upk.orig apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmrecords.cc apt-0.5.15lorg2/apt-pkg/rpm/rpmrecords.cc
--- apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmrecords.cc 2006-10-05 14:24:39 +0000
+++ apt-0.5.15lorg2/apt-pkg/rpm/rpmrecords.cc 2006-10-05 17:00:00 +0000
@@ -197,20 +197,22 @@ void rpmRecordParser::BufCat(const char
{
unsigned len = end - begin;
- if (BufUsed+len+1 >= BufSize)
+ while (BufUsed + len + 1 >= BufSize)
{
- BufSize += 512;
- char *tmp = (char*)realloc(Buffer, BufSize);
- if (tmp == NULL)
+ size_t new_size = BufSize + 512;
+ char *new_buf = (char*)realloc(Buffer, new_size);
+ if (new_buf == NULL)
{
_error->Errno("realloc", _("Could not allocate buffer for record text"));
return;
}
- Buffer = tmp;
+ Buffer = new_buf;
+ BufSize = new_size;
}
- strncpy(Buffer+BufUsed, begin, len);
+ memcpy(Buffer+BufUsed, begin, len);
BufUsed += len;
+ Buffer[BufUsed] = '\0';
}
void rpmRecordParser::BufCatTag(const char *tag, const char *value)
diff -upk.orig apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmsrcrecords.cc apt-0.5.15lorg2/apt-pkg/rpm/rpmsrcrecords.cc
--- apt-0.5.15lorg2.orig/apt-pkg/rpm/rpmsrcrecords.cc 2006-10-05 14:24:39 +0000
+++ apt-0.5.15lorg2/apt-pkg/rpm/rpmsrcrecords.cc 2006-10-05 17:00:06 +0000
@@ -220,20 +220,22 @@ void rpmSrcRecordParser::BufCat(char *be
{
unsigned len = end - begin;
- if (BufUsed+len+1 >= BufSize)
+ while (BufUsed + len + 1 >= BufSize)
{
- BufSize += 512;
- char *tmp = (char*)realloc(Buffer, BufSize);
- if (tmp == NULL)
+ size_t new_size = BufSize + 512;
+ char *new_buf = (char*)realloc(Buffer, new_size);
+ if (new_buf == NULL)
{
_error->Errno("realloc", _("Could not allocate buffer for record text"));
return;
}
- Buffer = tmp;
+ Buffer = new_buf;
+ BufSize = new_size;
}
- strncpy(Buffer+BufUsed, begin, len);
+ memcpy(Buffer+BufUsed, begin, len);
BufUsed += len;
+ Buffer[BufUsed] = '\0';
}
void rpmSrcRecordParser::BufCatTag(char *tag, char *value)