0001-core-fix-base64-decode-when-char-is-unsigned-fixes-2.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From d4083effab0f9bf76528d5c47198b17e7471ed13 Mon Sep 17 00:00:00 2001
  2. From: Glenn Strauss <gstrauss@gluelogic.com>
  3. Date: Thu, 21 Dec 2017 17:41:17 -0500
  4. Subject: [PATCH] [core] fix base64 decode when char is unsigned (fixes #2848)
  5. thx, codehero
  6. x-ref:
  7. "buffer_append_base64_decode() broken on compilers where char is assumed unsigned"
  8. https://redmine.lighttpd.net/issues/2848
  9. ---
  10. src/base64.c | 6 +++---
  11. 1 file changed, 3 insertions(+), 3 deletions(-)
  12. --- a/src/base64.c
  13. +++ b/src/base64.c
  14. @@ -11,7 +11,7 @@
  15. /* BASE64_STANDARD: "A-Z a-z 0-9 + /" maps to 0-63, pad with "=" */
  16. static const char base64_standard_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  17. -static const char base64_standard_reverse_table[] = {
  18. +static const signed char base64_standard_reverse_table[] = {
  19. /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
  20. -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x00 - 0x0F */
  21. -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x10 - 0x1F */
  22. @@ -25,7 +25,7 @@ static const char base64_standard_revers
  23. /* BASE64_URL: "A-Z a-z 0-9 - _" maps to 0-63, pad with "." */
  24. static const char base64_url_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.";
  25. -static const char base64_url_reverse_table[] = {
  26. +static const signed char base64_url_reverse_table[] = {
  27. /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
  28. -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x00 - 0x0F */
  29. -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, /* 0x10 - 0x1F */
  30. @@ -42,7 +42,7 @@ unsigned char* buffer_append_base64_deco
  31. size_t out_pos = 0; /* current output character (position) that is decoded. can contain partial result */
  32. unsigned int group = 0; /* how many base64 digits in the current group were decoded already. each group has up to 4 digits */
  33. size_t i;
  34. - const char *base64_reverse_table;
  35. + const signed char *base64_reverse_table;
  36. switch (charset) {
  37. case BASE64_STANDARD: