diff options
| author | Paul Eggert | 2018-12-26 01:11:58 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-12-26 01:12:32 -0800 |
| commit | b9c0ea6a6bc01c0034d00d685cab0de5953fdcc9 (patch) | |
| tree | 2a32981104292fbfd367e1ab61f845d9d1fc8ce0 | |
| parent | bbc7015e7bcb7ed569ea4d75672fcaacbe291f06 (diff) | |
| download | emacs-b9c0ea6a6bc01c0034d00d685cab0de5953fdcc9.tar.gz emacs-b9c0ea6a6bc01c0034d00d685cab0de5953fdcc9.zip | |
Port message-checksum to bignums
* lisp/gnus/message.el (message--rotate-fixnum-left): New function.
(message-checksum): Use it instead of assuming fixnum-only arithmetic.
This should fix Bug#33083.
| -rw-r--r-- | lisp/gnus/message.el | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index 03f80616d9e..dc15769a4fc 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el | |||
| @@ -5400,6 +5400,17 @@ Otherwise, generate and save a value for `canlock-password' first." | |||
| 5400 | (message "Denied posting -- only quoted text.") | 5400 | (message "Denied posting -- only quoted text.") |
| 5401 | nil))))))) | 5401 | nil))))))) |
| 5402 | 5402 | ||
| 5403 | (defun message--rotate-fixnum-left (n) | ||
| 5404 | "Rotate the fixnum N left by one bit in a fixnum word. | ||
| 5405 | The result is a fixnum." | ||
| 5406 | (logior (if (natnump n) 0 1) | ||
| 5407 | (ash (cond ((< (ash most-positive-fixnum -1) n) | ||
| 5408 | (logior n most-negative-fixnum)) | ||
| 5409 | ((< n (ash most-negative-fixnum -1)) | ||
| 5410 | (logand n most-positive-fixnum)) | ||
| 5411 | (n)) | ||
| 5412 | 1))) | ||
| 5413 | |||
| 5403 | (defun message-checksum () | 5414 | (defun message-checksum () |
| 5404 | "Return a \"checksum\" for the current buffer." | 5415 | "Return a \"checksum\" for the current buffer." |
| 5405 | (let ((sum 0)) | 5416 | (let ((sum 0)) |
| @@ -5409,7 +5420,7 @@ Otherwise, generate and save a value for `canlock-password' first." | |||
| 5409 | (concat "^" (regexp-quote mail-header-separator) "$")) | 5420 | (concat "^" (regexp-quote mail-header-separator) "$")) |
| 5410 | (while (not (eobp)) | 5421 | (while (not (eobp)) |
| 5411 | (when (not (looking-at "[ \t\n]")) | 5422 | (when (not (looking-at "[ \t\n]")) |
| 5412 | (setq sum (logxor (ash sum 1) (if (natnump sum) 0 1) | 5423 | (setq sum (logxor (message--rotate-fixnum-left sum) |
| 5413 | (char-after)))) | 5424 | (char-after)))) |
| 5414 | (forward-char 1))) | 5425 | (forward-char 1))) |
| 5415 | sum)) | 5426 | sum)) |