diff options
author | David Kalnischkies <david@kalnischkies.de> | 2020-12-03 10:41:43 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2021-02-03 17:36:45 +0100 |
commit | 10f13938bbf1474451fadcd62e1c31c4b5f5b3d7 (patch) | |
tree | dcf18bfced7c4447eb5ed212f8026a2df0354335 /apt-pkg/contrib/strutl.cc | |
parent | 03790b071d6a97374a03af36eda5698a143300b0 (diff) |
Fix incorrect base64 encoding due to int promotion
For \xff and friends with the highest bit set and hence being a negative
value on signed char systems the wrong encoding is produced as we run
into undefined behaviour accessing negative array indexes.
We can avoid this problem simply by using an unsigned data type.
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index bd4856526..826b21478 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -597,7 +597,7 @@ string Base64Encode(const string &S) base64. */ for (string::const_iterator I = S.begin(); I < S.end(); I += 3) { - char Bits[3] = {0,0,0}; + uint8_t Bits[3] = {0,0,0}; Bits[0] = I[0]; if (I + 1 < S.end()) Bits[1] = I[1]; |