diff --git a/apt-0.5.15lorg2-alt-realloc.patch b/apt-0.5.15lorg2-alt-realloc.patch deleted file mode 100644 index 4dc2615..0000000 --- a/apt-0.5.15lorg2-alt-realloc.patch +++ /dev/null @@ -1,64 +0,0 @@ -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) diff --git a/apt/apt-pkg/rpm/rpmrecords.cc b/apt/apt-pkg/rpm/rpmrecords.cc index 5763e60..9c674e4 100644 --- a/apt/apt-pkg/rpm/rpmrecords.cc +++ b/apt/apt-pkg/rpm/rpmrecords.cc @@ -218,20 +218,22 @@ void rpmRecordParser::BufCat(const char *begin, const char *end) { 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 --git a/apt/apt-pkg/rpm/rpmsrcrecords.cc b/apt/apt-pkg/rpm/rpmsrcrecords.cc index 9cb5006..4c9b36f 100644 --- a/apt/apt-pkg/rpm/rpmsrcrecords.cc +++ b/apt/apt-pkg/rpm/rpmsrcrecords.cc @@ -240,20 +240,22 @@ void rpmSrcRecordParser::BufCat(const char *begin, const char *end) { 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(const char *tag, const char *value)