]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-extracttemplates.cc
improve pkgTagSection scanning and parsing
[apt.git] / cmdline / apt-extracttemplates.cc
index e4428e05154e26ad2b4cef7d36a0423965702242..7be59b9f81cae3cf7b1b7a2002fa843b308209e4 100644 (file)
@@ -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);