diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-05-10 11:24:44 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-05-10 11:24:44 +0200 |
commit | 8710a36a01c0cb1648926792c2ad05185535558e (patch) | |
tree | 0f4bc04b87ae5926d9f855f7268ee84802232749 /cmdline/apt-extracttemplates.cc | |
parent | ffe3c68e494efc1c2c4d748fa9d69e150867e5c2 (diff) |
improve pkgTagSection scanning and parsing
Removes the 256 fields limit, deals consistently with spaces littered
all over the place and is even a tiny bit faster than before.
Even comes with a bunch of new tests to validate these claims.
Diffstat (limited to 'cmdline/apt-extracttemplates.cc')
-rw-r--r-- | cmdline/apt-extracttemplates.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmdline/apt-extracttemplates.cc b/cmdline/apt-extracttemplates.cc index e4428e051..7be59b9f8 100644 --- a/cmdline/apt-extracttemplates.cc +++ b/cmdline/apt-extracttemplates.cc @@ -103,10 +103,12 @@ bool DebFile::DoItem(Item &I, int &Fd) if (strcmp(I.Name, "control") == 0) { delete [] Control; - Control = new char[I.Size+1]; - Control[I.Size] = 0; + Control = new char[I.Size+3]; + Control[I.Size] = '\n'; + Control[I.Size + 1] = '\n'; + Control[I.Size + 2] = '\0'; Which = IsControl; - ControlLen = I.Size; + ControlLen = I.Size + 3; // make it call the Process method below. this is so evil Fd = -2; } @@ -162,9 +164,10 @@ bool DebFile::Process(Item &/*I*/, const unsigned char *data, bool DebFile::ParseInfo() { if (Control == NULL) return false; - + pkgTagSection Section; - Section.Scan(Control, ControlLen); + if (Section.Scan(Control, ControlLen) == false) + return false; Package = Section.FindS("Package"); Version = GetInstalledVer(Package); |