Fix realloc(3) usage.
This commit is contained in:
parent
6b8849f508
commit
d9cc297848
64
apt-0.5.15lorg2-alt-realloc.patch
Normal file
64
apt-0.5.15lorg2-alt-realloc.patch
Normal file
@ -0,0 +1,64 @@
|
||||
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)
|
2
apt.spec
2
apt.spec
@ -57,6 +57,7 @@ Patch43: apt-0.5.15cnc6-apt-utils-locale.patch
|
||||
Patch44: apt-0.5.15lorg2-alt-apt-shell-resetconfig.patch
|
||||
Patch45: apt-0.5.15lorg2-alt-pkgInitConfig-cpu.patch
|
||||
Patch46: apt-0.5.15lorg2-alt-pkgCache-PrvIterator.patch
|
||||
Patch47: apt-0.5.15lorg2-alt-realloc.patch
|
||||
|
||||
# Normally not applied, but useful.
|
||||
Patch101: apt-0.5.4cnc9-alt-getsrc-debug.patch
|
||||
@ -258,6 +259,7 @@ This package contains method 'rsync' for APT.
|
||||
%patch44 -p1
|
||||
%patch45 -p1
|
||||
%patch46 -p1
|
||||
%patch47 -p1
|
||||
|
||||
find -type f -name \*.orig -delete -print
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user