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)