aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias EngdegÄrd2021-12-20 18:17:23 +0100
committerMattias EngdegÄrd2021-12-20 20:22:09 +0100
commita34650acff3740980ef23d900d35004bcfe2ef04 (patch)
tree5e34b2538df2849832e3971bc7d0cd9546b5adc9 /src
parent27be90154d1a4b19efe30c97f221b29e3becc920 (diff)
downloademacs-a34650acff3740980ef23d900d35004bcfe2ef04.tar.gz
emacs-a34650acff3740980ef23d900d35004bcfe2ef04.zip
Fix sloppy base64 acceptance of some multibyte characters
The base64 encoding functions incorrectly accepted some multibyte characters; stop doing that (bug#52670). * src/fns.c (base64_encode_1): Reject all multibyte characters. * test/src/fns-tests.el (fns-tests-base64-encode-string) (fns-test-base64url-encode-region) (fns-test-base64url-encode-string): Add tests. * doc/lispref/text.texi (Base 64): Rephrase outdated manual text. * etc/NEWS: Add a notice.
Diffstat (limited to 'src')
-rw-r--r--src/fns.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/fns.c b/src/fns.c
index 76c76c92ba9..23721334f76 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -3653,7 +3653,7 @@ base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3653 c = string_char_and_length ((unsigned char *) from + i, &bytes); 3653 c = string_char_and_length ((unsigned char *) from + i, &bytes);
3654 if (CHAR_BYTE8_P (c)) 3654 if (CHAR_BYTE8_P (c))
3655 c = CHAR_TO_BYTE8 (c); 3655 c = CHAR_TO_BYTE8 (c);
3656 else if (c >= 256) 3656 else if (c >= 128)
3657 return -1; 3657 return -1;
3658 i += bytes; 3658 i += bytes;
3659 } 3659 }
@@ -3696,7 +3696,7 @@ base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3696 c = string_char_and_length ((unsigned char *) from + i, &bytes); 3696 c = string_char_and_length ((unsigned char *) from + i, &bytes);
3697 if (CHAR_BYTE8_P (c)) 3697 if (CHAR_BYTE8_P (c))
3698 c = CHAR_TO_BYTE8 (c); 3698 c = CHAR_TO_BYTE8 (c);
3699 else if (c >= 256) 3699 else if (c >= 128)
3700 return -1; 3700 return -1;
3701 i += bytes; 3701 i += bytes;
3702 } 3702 }
@@ -3721,7 +3721,7 @@ base64_encode_1 (const char *from, char *to, ptrdiff_t length,
3721 c = string_char_and_length ((unsigned char *) from + i, &bytes); 3721 c = string_char_and_length ((unsigned char *) from + i, &bytes);
3722 if (CHAR_BYTE8_P (c)) 3722 if (CHAR_BYTE8_P (c))
3723 c = CHAR_TO_BYTE8 (c); 3723 c = CHAR_TO_BYTE8 (c);
3724 else if (c >= 256) 3724 else if (c >= 128)
3725 return -1; 3725 return -1;
3726 i += bytes; 3726 i += bytes;
3727 } 3727 }