Apply apt-0.5.15lorg2-alt-realloc.patch
Added in commit d9cc297
:
Fix realloc(3) usage.
This commit is contained in:
parent
3fb1186bee
commit
b99eba002f
@ -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)
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user