From 266b7c7b0bc9d0b6c33c664248904398b9d48479 Mon Sep 17 00:00:00 2001 From: Paul Nasrat Date: Wed, 14 Nov 2007 20:07:38 +0000 Subject: [PATCH] - Fix base64 assumption of signed char, from Tomas Mraz (#380911) --- rpm-4.4.2.2-base64-unsigned-char.patch | 102 +++++++++++++++++++++++++ rpm.spec | 7 +- 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 rpm-4.4.2.2-base64-unsigned-char.patch diff --git a/rpm-4.4.2.2-base64-unsigned-char.patch b/rpm-4.4.2.2-base64-unsigned-char.patch new file mode 100644 index 0000000..e5c42b4 --- /dev/null +++ b/rpm-4.4.2.2-base64-unsigned-char.patch @@ -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; diff --git a/rpm.spec b/rpm.spec index b6089ba..70163d2 100644 --- a/rpm.spec +++ b/rpm.spec @@ -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 4.4.2.2-9 +- Fix base64 assumption of signed char, from Tomas Mraz (#380911) + * Mon Nov 12 2007 Panu Matilainen 4.4.2.2-8 - Use NSS instead of beecrypt for cryptography, from Tomas Mraz (#348131) - Update build + other dependencies accordingly