all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: mgcyung <mgcyung@gmail.com>
To: 37758@debbugs.gnu.org
Subject: bug#37758: 27.0.50; Support multibyte characters in function 'auth-source--pad'an; with patch
Date: Tue, 15 Oct 2019 10:49:46 +0800	[thread overview]
Message-ID: <875zkqd8ol.wl-mgcyung@gmail.com> (raw)

[-- 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 --]




             reply	other threads:[~2019-10-15  2:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15  2:49 mgcyung [this message]
2019-10-15  6:43 ` bug#37758: 27.0.50; Support multibyte characters in function 'auth-source--pad'an; with patch Lars Ingebrigtsen
2019-10-15 10:58   ` mgcyung
2019-10-16  1:32     ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zkqd8ol.wl-mgcyung@gmail.com \
    --to=mgcyung@gmail.com \
    --cc=37758@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.