From 2f6557b96c08c1adebf3b1e292ae636a27f624d0 Mon Sep 17 00:00:00 2001
From: David Kalnischkies <kalnischkies@gmail.com>
Date: Tue, 30 Nov 2010 18:57:42 +0100
Subject: add the possibility to disable only the progress reporting stuff as
 the quiet level 1 does this, but also disables other stuff we might want to
 test against in a testcase

---
 apt-pkg/contrib/progress.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'apt-pkg/contrib')

diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index cffdddc4f..45e81edcb 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -135,7 +135,7 @@ bool OpProgress::CheckChange(float Interval)
 OpTextProgress::OpTextProgress(Configuration &Config) : 
                                NoUpdate(false), NoDisplay(false), LastLen(0) 
 {
-   if (Config.FindI("quiet",0) >= 1)
+   if (Config.FindI("quiet",0) >= 1 || Config.FindB("quiet::NoUpdate", false) == true)
       NoUpdate = true;
    if (Config.FindI("quiet",0) >= 2)
       NoDisplay = true;
-- 
cgit v1.2.3


From 54f2f0a3e46e4369285be8c25912fd45413114c0 Mon Sep 17 00:00:00 2001
From: Nobuhiro Hayashi <nobuhiro.hayashi@gmail.com>
Date: Fri, 3 Dec 2010 12:09:09 +0900
Subject: Permit base256 encoded value in the numeric field of tar header.

---
 apt-pkg/contrib/strutl.cc | 18 ++++++++++++++++++
 apt-pkg/contrib/strutl.h  |  1 +
 2 files changed, 19 insertions(+)

(limited to 'apt-pkg/contrib')

diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 987f4c3a4..daf87c87f 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -968,6 +968,24 @@ bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
    return true;
 }
 									/*}}}*/
+// Base256ToNum - Convert a fixed length binary to a number             /*{{{*/
+// ---------------------------------------------------------------------
+/* This is used in decoding the 256bit encoded fixed length fields in
+   tar files */
+bool Base256ToNum(const char *Str,unsigned long &Res,unsigned Len)
+{
+   int i;
+   if ((Str[0] & 0x80) == 0)
+      return false;
+   else
+   {
+      Res = Str[0] & 0x7F;
+      for(i=1; i<Len; i++)
+         Res = (Res<<8) + Str[i];
+      return true;
+   }
+}
+									/*}}}*/
 // HexDigit - Convert a hex character into an integer			/*{{{*/
 // ---------------------------------------------------------------------
 /* Helper for Hex2Num */
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index a457ff047..591c992d0 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -52,6 +52,7 @@ string LookupTag(const string &Message,const char *Tag,const char *Default = 0);
 int StringToBool(const string &Text,int Default = -1);
 bool ReadMessages(int Fd, vector<string> &List);
 bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
+bool Base256ToNum(const char *Str,unsigned long &Res,unsigned Len);
 bool Hex2Num(const string &Str,unsigned char *Num,unsigned int Length);
 bool TokSplitString(char Tok,char *Input,char **List,
 		    unsigned long ListMax);
-- 
cgit v1.2.3


From 36f1098aed548651a32a2c15cc9ad80c4330b4d9 Mon Sep 17 00:00:00 2001
From: David Kalnischkies <kalnischkies@gmail.com>
Date: Wed, 12 Jan 2011 17:09:04 +0100
Subject: * apt-pkg/contrib/fileutl.cc:   - add a RealFileExists method and
 check that your configuration files     are real files to avoid endless loops
 if not (Closes: #604401)

---
 apt-pkg/contrib/fileutl.cc | 20 +++++++++++++++++++-
 apt-pkg/contrib/fileutl.h  |  1 +
 2 files changed, 20 insertions(+), 1 deletion(-)

(limited to 'apt-pkg/contrib')

diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index f4ab066d7..db6057ea3 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -191,7 +191,7 @@ int GetLock(string File,bool Errors)
 									/*}}}*/
 // FileExists - Check if a file exists					/*{{{*/
 // ---------------------------------------------------------------------
-/* */
+/* Beware: Directories are also files! */
 bool FileExists(string File)
 {
    struct stat Buf;
@@ -200,6 +200,17 @@ bool FileExists(string File)
    return true;
 }
 									/*}}}*/
+// RealFileExists - Check if a file exists and if it is really a file	/*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool RealFileExists(string File)
+{
+   struct stat Buf;
+   if (stat(File.c_str(),&Buf) != 0)
+      return false;
+   return ((Buf.st_mode & S_IFREG) != 0);
+}
+									/*}}}*/
 // DirectoryExists - Check if a directory exists and is really one	/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -304,6 +315,13 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
    }
 
    std::vector<string> List;
+
+   if (DirectoryExists(Dir.c_str()) == false)
+   {
+      _error->Error(_("List of files can't be created as '%s' is not a directory"), Dir.c_str());
+      return List;
+   }
+
    Configuration::MatchAgainstConfig SilentIgnore("Dir::Ignore-Files-Silently");
    DIR *D = opendir(Dir.c_str());
    if (D == 0) 
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 1380f06b4..146d917d8 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -93,6 +93,7 @@ bool RunScripts(const char *Cnf);
 bool CopyFile(FileFd &From,FileFd &To);
 int GetLock(string File,bool Errors = true);
 bool FileExists(string File);
+bool RealFileExists(string File);
 bool DirectoryExists(string const &Path) __attrib_const;
 bool CreateDirectory(string const &Parent, string const &Path);
 
-- 
cgit v1.2.3


From c65607c5ecc2c3a16d3432583dd859d6fb2dc3aa Mon Sep 17 00:00:00 2001
From: David Kalnischkies <kalnischkies@gmail.com>
Date: Wed, 12 Jan 2011 17:15:26 +0100
Subject: * apt-pkg/contrib/weakptr.h:   - include stddefs.h to fix compile
 error (undefined NULL) with gcc-4.6

---
 apt-pkg/contrib/weakptr.h | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'apt-pkg/contrib')

diff --git a/apt-pkg/contrib/weakptr.h b/apt-pkg/contrib/weakptr.h
index 5158e393c..8de727d89 100644
--- a/apt-pkg/contrib/weakptr.h
+++ b/apt-pkg/contrib/weakptr.h
@@ -22,6 +22,8 @@
 #define WEAK_POINTER_H
 
 #include <set>
+#include <stddef.h>
+
 /**
  * Class for objects providing support for weak pointers.
  *
-- 
cgit v1.2.3


From 491058e3570ec66769c4e7e9797f549c6d724848 Mon Sep 17 00:00:00 2001
From: David Kalnischkies <kalnischkies@gmail.com>
Date: Thu, 13 Jan 2011 23:22:17 +0100
Subject: ignore non-regular files in GetListOfFilesInDir (Closes: #594694)

---
 apt-pkg/contrib/fileutl.cc | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

(limited to 'apt-pkg/contrib')

diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index db6057ea3..52f517ee0 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -336,6 +336,20 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
       if (Ent->d_name[0] == '.')
 	 continue;
 
+      // Make sure it is a file and not something else
+      string const File = flCombine(Dir,Ent->d_name);
+#ifdef _DIRENT_HAVE_D_TYPE
+      if (Ent->d_type != DT_REG)
+#endif
+      {
+	 if (RealFileExists(File.c_str()) == false)
+	 {
+	    if (SilentIgnore.Match(Ent->d_name) == false)
+	       _error->Notice(_("Ignoring '%s' in directory '%s' as it is not a regular file"), Ent->d_name, Dir.c_str());
+	    continue;
+	 }
+      }
+
       // check for accepted extension:
       // no extension given -> periods are bad as hell!
       // extensions given -> "" extension allows no extension
@@ -349,7 +363,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
 	       if (Debug == true)
 		  std::clog << "Bad file: " << Ent->d_name << " → no extension" << std::endl;
 	       if (SilentIgnore.Match(Ent->d_name) == false)
-		  _error->Notice("Ignoring file '%s' in directory '%s' as it has no filename extension", Ent->d_name, Dir.c_str());
+		  _error->Notice(_("Ignoring file '%s' in directory '%s' as it has no filename extension"), Ent->d_name, Dir.c_str());
 	       continue;
 	    }
 	 }
@@ -358,7 +372,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
 	    if (Debug == true)
 	       std::clog << "Bad file: " << Ent->d_name << " → bad extension »" << flExtension(Ent->d_name) << "«" << std::endl;
 	    if (SilentIgnore.Match(Ent->d_name) == false)
-	       _error->Notice("Ignoring file '%s' in directory '%s' as it has an invalid filename extension", Ent->d_name, Dir.c_str());
+	       _error->Notice(_("Ignoring file '%s' in directory '%s' as it has an invalid filename extension"), Ent->d_name, Dir.c_str());
 	    continue;
 	 }
       }
@@ -391,16 +405,6 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c
 	 continue;
       }
 
-      // Make sure it is a file and not something else
-      string const File = flCombine(Dir,Ent->d_name);
-      struct stat St;
-      if (stat(File.c_str(),&St) != 0 || S_ISREG(St.st_mode) == 0)
-      {
-	 if (Debug == true)
-	    std::clog << "Bad file: " << Ent->d_name << " → stat says not a good file" << std::endl;
-	 continue;
-      }
-
       if (Debug == true)
 	 std::clog << "Accept file: " << Ent->d_name << " in " << Dir << std::endl;
       List.push_back(File);
-- 
cgit v1.2.3


From caffd4807f612e931ecca8f7d9b0c0c10de27ce6 Mon Sep 17 00:00:00 2001
From: David Kalnischkies <kalnischkies@gmail.com>
Date: Sat, 15 Jan 2011 20:28:03 +0100
Subject: * methods/rred.cc:   - operate optional on gzip compressed pdiffs *
 apt-pkg/acquire-item.cc:   - don't uncompress downloaded pdiff files before
 feeding it to rred

---
 apt-pkg/contrib/fileutl.h | 1 +
 1 file changed, 1 insertion(+)

(limited to 'apt-pkg/contrib')

diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 146d917d8..cde288ad2 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -72,6 +72,7 @@ class FileFd
    // Simple manipulators
    inline int Fd() {return iFd;};
    inline void Fd(int fd) {iFd = fd;};
+   inline gzFile gzFd() {return gz;};
    inline bool IsOpen() {return iFd >= 0;};
    inline bool Failed() {return (Flags & Fail) == Fail;};
    inline void EraseOnFailure() {Flags |= DelOnFail;};
-- 
cgit v1.2.3