- Fix base64 assumption of signed char, from Tomas Mraz (#380911)

This commit is contained in:
Paul Nasrat 2007-11-14 20:07:38 +00:00
parent 34fad67758
commit 266b7c7b0b
2 changed files with 108 additions and 1 deletions

View File

@ -0,0 +1,102 @@
diff -r 39cb695c7c8b rpmio/base64.c
--- a/rpmio/base64.c Thu Nov 01 10:42:01 2007 +0100
+++ b/rpmio/base64.c Wed Nov 14 18:16:51 2007 +0100
@@ -98,21 +98,20 @@ char *b64encode(const void *data, size_t
return output;
}
-static int base64_decode_value(char value_in)
-{
- static const char decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
- static const char decoding_size = sizeof(decoding);
+static int base64_decode_value(unsigned char value_in)
+{
+ static const int decoding[] = {62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-2,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51};
value_in -= 43;
- if (value_in < 0 || value_in > decoding_size)
+ if (value_in > sizeof(decoding)/sizeof(int))
return -1;
- return decoding[(int)value_in];
+ return decoding[value_in];
}
static size_t base64_decode_block(const char *code_in, const size_t length_in, char *plaintext_out)
{
const char *codechar = code_in;
char *plainchar = plaintext_out;
- char fragment;
+ int fragment;
*plainchar = 0;
@@ -123,38 +122,38 @@ static size_t base64_decode_block(const
{
return plainchar - plaintext_out;
}
- fragment = (char)base64_decode_value(*codechar++);
- } while (fragment < 0);
- *plainchar = (fragment & 0x03f) << 2;
-
- do {
- if (codechar == code_in+length_in)
- {
- return plainchar - plaintext_out;
- }
- fragment = (char)base64_decode_value(*codechar++);
- } while (fragment < 0);
- *plainchar++ |= (fragment & 0x030) >> 4;
- *plainchar = (fragment & 0x00f) << 4;
-
- do {
- if (codechar == code_in+length_in)
- {
- return plainchar - plaintext_out;
- }
- fragment = (char)base64_decode_value(*codechar++);
- } while (fragment < 0);
- *plainchar++ |= (fragment & 0x03c) >> 2;
- *plainchar = (fragment & 0x003) << 6;
-
- do {
- if (codechar == code_in+length_in)
- {
- return plainchar - plaintext_out;
- }
- fragment = (char)base64_decode_value(*codechar++);
- } while (fragment < 0);
- *plainchar++ |= (fragment & 0x03f);
+ fragment = base64_decode_value(*codechar++);
+ } while (fragment < 0);
+ *plainchar = (char)((fragment & 0x03f) << 2);
+
+ do {
+ if (codechar == code_in+length_in)
+ {
+ return plainchar - plaintext_out;
+ }
+ fragment = base64_decode_value(*codechar++);
+ } while (fragment < 0);
+ *plainchar++ |= (char)((fragment & 0x030) >> 4);
+ *plainchar = (char)((fragment & 0x00f) << 4);
+
+ do {
+ if (codechar == code_in+length_in)
+ {
+ return plainchar - plaintext_out;
+ }
+ fragment = base64_decode_value(*codechar++);
+ } while (fragment < 0);
+ *plainchar++ |= (char)((fragment & 0x03c) >> 2);
+ *plainchar = (char)((fragment & 0x003) << 6);
+
+ do {
+ if (codechar == code_in+length_in)
+ {
+ return plainchar - plaintext_out;
+ }
+ fragment = base64_decode_value(*codechar++);
+ } while (fragment < 0);
+ *plainchar++ |= (char)(fragment & 0x03f);
}
/* control should not reach here */
return plainchar - plaintext_out;

View File

@ -6,7 +6,7 @@
Summary: The RPM package management system
Name: rpm
Version: 4.4.2.2
Release: 8%{?dist}
Release: 9%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source: http://rpm.org/releases/rpm-4.4.x/%{name}-%{version}.tar.gz
@ -23,6 +23,7 @@ Patch10: rpm-4.4.2.2-debugedit-fpc.patch
Patch11: rpm-4.4.2.2-pyproblem.patch
Patch12: rpm-4.4.2.2-problem-nevra.patch
Patch13: rpm-4.4.2.2-nss.patch
Patch14: rpm-4.4.2.2-base64-unsigned-char.patch
# XXX Beware, this is one murky license, partially GPL/LGPL dual-licensed
# and several different components with their own licenses included...
@ -151,6 +152,7 @@ that will manipulate RPM packages and databases.
%patch11 -p1 -b .pyproblem
%patch12 -p1 -b .problem-nevra
%patch13 -p1 -b .nss
%patch14 -p1 -b .base64
# force external popt
rm -rf popt/
@ -413,6 +415,9 @@ exit 0
%endif
%changelog
* Wed Nov 14 2007 Paul Nasrat <pauln@truemesh.com> 4.4.2.2-9
- Fix base64 assumption of signed char, from Tomas Mraz (#380911)
* Mon Nov 12 2007 Panu Matilainen <pmatilai@redhat.com> 4.4.2.2-8
- Use NSS instead of beecrypt for cryptography, from Tomas Mraz (#348131)
- Update build + other dependencies accordingly