all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#37758: 27.0.50; Support multibyte characters in function 'auth-source--pad'an; with patch
@ 2019-10-15  2:49 mgcyung
  2019-10-15  6:43 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: mgcyung @ 2019-10-15  2:49 UTC (permalink / raw)
  To: 37758

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]


'auth-source--pad' use 'length' to get byte length of a
string. However, 'length' return the number of characters which is not
the byte length with multibyte characters such as Chinese
character. This may causes an error "GnuTLS cipher
AES-256-CBC/encrypt input block length xxxx is not a multiple of the
required 16".

According to the doc of 'length'. 'length' can be replaced by
'string-bytes'. And a patch is attached.


[-- Attachment #2: auth-source--pad_byte-length.patch --]
[-- Type: application/octet-stream, Size: 817 bytes --]

diff --git a/lisp/auth-source.el b/lisp/auth-source.el
index 9061d41556..80559b8f47 100644
--- a/lisp/auth-source.el
+++ b/lisp/auth-source.el
@@ -1190,13 +1190,13 @@ FILE is the file from which we obtained this token."
 
 (defun auth-source--pad (string length)
   "Pad string S to a modulo of LENGTH."
-  (let ((pad (- length (mod (length string) length))))
+  (let ((pad (- length (mod (string-bytes string) length))))
     (concat string (make-string pad pad))))
 
 (defun auth-source--unpad (string)
   "Remove PKCS#7 padding from STRING."
-  (substring string 0 (- (length string)
-			 (aref string (1- (length string))))))
+  (substring string 0 (- (string-bytes string)
+			 (aref string (1- (string-bytes string))))))
 
 (defun auth-source--deobfuscate (data)
   (if (and (fboundp 'gnutls-symmetric-encrypt)

[-- Attachment #3: Type: text/plain, Size: 2 bytes --]




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-16  1:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-15  2:49 bug#37758: 27.0.50; Support multibyte characters in function 'auth-source--pad'an; with patch mgcyung
2019-10-15  6:43 ` Lars Ingebrigtsen
2019-10-15 10:58   ` mgcyung
2019-10-16  1:32     ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.