summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/hashes.cc2
-rw-r--r--apt-pkg/contrib/hashes.h8
-rw-r--r--apt-pkg/contrib/hashsum_template.h12
-rw-r--r--apt-pkg/contrib/md5.cc2
-rw-r--r--apt-pkg/contrib/md5.h2
-rw-r--r--apt-pkg/contrib/sha1.cc2
-rw-r--r--apt-pkg/contrib/sha1.h2
-rw-r--r--apt-pkg/contrib/sha2.h6
-rw-r--r--apt-pkg/contrib/strutl.cc3
9 files changed, 23 insertions, 16 deletions
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 755ad2035..662c2bf8b 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -312,6 +312,8 @@ public:
// Hashes::Add* - Add the contents of data or FD /*{{{*/
bool Hashes::Add(const unsigned char * const Data, unsigned long long const Size)
{
+ if (Size == 0)
+ return true;
bool Res = true;
APT_IGNORE_DEPRECATED_PUSH
if ((d->CalcHashes & MD5SUM) == MD5SUM)
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 9bfc32c54..1fe0afc00 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -195,11 +195,11 @@ class Hashes
static const int UntilEOF = 0;
- bool Add(const unsigned char * const Data, unsigned long long const Size);
- APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool Add(const unsigned char * const Data, unsigned long long const Size, unsigned int const Hashes);
- inline bool Add(const char * const Data)
+ bool Add(const unsigned char * const Data, unsigned long long const Size) APT_NONNULL(2);
+ APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool Add(const unsigned char * const Data, unsigned long long const Size, unsigned int const Hashes) APT_NONNULL(2);
+ inline bool Add(const char * const Data) APT_NONNULL(2)
{return Add((unsigned char const * const)Data,strlen(Data));};
- inline bool Add(const unsigned char * const Beg,const unsigned char * const End)
+ inline bool Add(const unsigned char * const Beg,const unsigned char * const End) APT_NONNULL(2,3)
{return Add(Beg,End-Beg);};
enum SupportedHashes { MD5SUM = (1 << 0), SHA1SUM = (1 << 1), SHA256SUM = (1 << 2),
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 4000f230d..e5032d02f 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -122,18 +122,18 @@ class HashSumValue
class SummationImplementation
{
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0;
- inline bool Add(const char *inbuf, unsigned long long const inlen)
+ virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_NONNULL(2) = 0;
+ inline bool Add(const char *inbuf, unsigned long long const inlen) APT_NONNULL(2)
{ return Add((const unsigned char *)inbuf, inlen); }
- inline bool Add(const unsigned char *Data)
+ inline bool Add(const unsigned char *Data) APT_NONNULL(2)
{ return Add(Data, strlen((const char *)Data)); }
- inline bool Add(const char *Data)
+ inline bool Add(const char *Data) APT_NONNULL(2)
{ return Add((const unsigned char *)Data, strlen(Data)); }
- inline bool Add(const unsigned char *Beg, const unsigned char *End)
+ inline bool Add(const unsigned char *Beg, const unsigned char *End) APT_NONNULL(2,3)
{ return Add(Beg, End - Beg); }
- inline bool Add(const char *Beg, const char *End)
+ inline bool Add(const char *Beg, const char *End) APT_NONNULL(2,3)
{ return Add((const unsigned char *)Beg, End - Beg); }
bool AddFD(int Fd, unsigned long long Size = 0);
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index b487a96f9..ff7868fe2 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -187,6 +187,8 @@ bool MD5Summation::Add(const unsigned char *data,unsigned long long len)
{
if (Done == true)
return false;
+ if (len == 0)
+ return true;
uint32_t *buf = (uint32_t *)Buf;
uint32_t *bytes = (uint32_t *)Bytes;
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index a16ea4d2d..a286f092a 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -48,7 +48,7 @@ class MD5Summation : public SummationImplementation
public:
- bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE;
+ bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE APT_NONNULL(2);
using SummationImplementation::Add;
MD5SumValue Result();
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index bf6bc6cb6..298a7799b 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -243,6 +243,8 @@ bool SHA1Summation::Add(const unsigned char *data,unsigned long long len)
{
if (Done)
return false;
+ if (len == 0)
+ return true;
uint32_t *state = (uint32_t *)State;
uint32_t *count = (uint32_t *)Count;
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index 1c5cb5aa1..3387c1cfd 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -37,7 +37,7 @@ class SHA1Summation : public SummationImplementation
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE;
+ bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_OVERRIDE APT_NONNULL(2);
using SummationImplementation::Add;
SHA1SumValue Result();
diff --git a/apt-pkg/contrib/sha2.h b/apt-pkg/contrib/sha2.h
index 8b4bdd439..164840d3b 100644
--- a/apt-pkg/contrib/sha2.h
+++ b/apt-pkg/contrib/sha2.h
@@ -34,7 +34,7 @@ class SHA2SummationBase : public SummationImplementation
protected:
bool Done;
public:
- bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE = 0;
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE APT_NONNULL(2) = 0;
void Result();
};
@@ -45,7 +45,7 @@ class SHA256Summation : public SHA2SummationBase
unsigned char Sum[32];
public:
- bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE APT_NONNULL(2)
{
if (Done)
return false;
@@ -78,7 +78,7 @@ class SHA512Summation : public SHA2SummationBase
unsigned char Sum[64];
public:
- bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE
+ bool Add(const unsigned char *inbuf, unsigned long long len) APT_OVERRIDE APT_NONNULL(2)
{
if (Done)
return false;
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 66b0078dc..cf8feb970 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1171,10 +1171,11 @@ bool Base256ToNum(const char *Str,unsigned long long &Res,unsigned int Len)
tar files */
bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len)
{
- unsigned long long Num;
+ unsigned long long Num = 0;
bool rc;
rc = Base256ToNum(Str, Num, Len);
+ // rudimentary check for overflow (Res = ulong, Num = ulonglong)
Res = Num;
if (Res != Num)
return false;