summaryrefslogtreecommitdiff
path: root/ftparchive/sources.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-03-09 01:34:10 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2015-03-16 17:59:31 +0100
commitd61960d9244340956a27f4ca46aecd15cc75e18b (patch)
treec8f7cb33e08c84bcf06fbff39647dc03bc103afb /ftparchive/sources.cc
parentb0be0e09cfbbcb033eb0b92eaf17ac31a6b9f423 (diff)
parent1a0619ac765cc0b2f4906c96c1a4d7f510569a3f (diff)
merge debian/sid into debian/experimental
Diffstat (limited to 'ftparchive/sources.cc')
-rw-r--r--ftparchive/sources.cc41
1 files changed, 27 insertions, 14 deletions
diff --git a/ftparchive/sources.cc b/ftparchive/sources.cc
index d0878a70a..ab976b490 100644
--- a/ftparchive/sources.cc
+++ b/ftparchive/sources.cc
@@ -1,5 +1,5 @@
#include <string>
-#include <iostream>
+#include <sstream>
// for memcpy
#include <cstring>
@@ -9,17 +9,19 @@
#include "sources.h"
-bool DscExtract::TakeDsc(const void *newData, unsigned long newSize)
+bool DscExtract::TakeDsc(const void *newData, unsigned long long newSize)
{
- if(newSize > maxSize)
- return _error->Error("DSC data is too large %lu!", newSize);
-
if (newSize == 0)
{
+ // adding two newlines 'off record' for pkgTagSection.Scan() calls
+ Data = "\n\n";
Length = 0;
return true;
}
- memcpy(Data, newData, newSize);
+
+ Data = std::string((const char*)newData, newSize);
+ // adding two newlines 'off record' for pkgTagSection.Scan() calls
+ Data.append("\n\n");
Length = newSize;
return true;
@@ -27,20 +29,31 @@ bool DscExtract::TakeDsc(const void *newData, unsigned long newSize)
bool DscExtract::Read(std::string FileName)
{
+ Data.clear();
+ Length = 0;
+
FileFd F;
if (OpenMaybeClearSignedFile(FileName, F) == false)
return false;
-
- unsigned long long const FSize = F.FileSize();
- if(FSize > maxSize)
- return _error->Error("DSC file '%s' is too large!",FileName.c_str());
-
- if (F.Read(Data, FSize) == false)
- return false;
- Length = FSize;
IsClearSigned = (FileName != F.Name());
+ std::ostringstream data;
+ char buffer[1024];
+ do {
+ unsigned long long actual = 0;
+ if (F.Read(buffer, sizeof(buffer)-1, &actual) == false)
+ return _error->Errno("read", "Failed to read dsc file %s", FileName.c_str());
+ if (actual == 0)
+ break;
+ Length += actual;
+ buffer[actual] = '\0';
+ data << buffer;
+ } while(true);
+
+ // adding two newlines 'off record' for pkgTagSection.Scan() calls
+ data << "\n\n";
+ Data = data.str();
return true;
}