diff options
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/tar-mode.el | 26 |
2 files changed, 29 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 595b7fc953f..a33c1ea66f7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2009-03-13 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * tar-mode.el (tar-header-block-tokenize): Presume less, check more. | ||
| 4 | (tar-summarize-buffer): Don't silently skip incomplete headers. | ||
| 5 | (tar-mode): Revert to fundamental-mode in case of malformed tar data. | ||
| 6 | (tar-extract): Try to make sure set-auto-mode doesn't mistakenly | ||
| 7 | treat a tar file member as being a tar file itself, just because | ||
| 8 | its own filename includes the parent tar file's. | ||
| 9 | |||
| 1 | 2009-03-13 Kenichi Handa <handa@m17n.org> | 10 | 2009-03-13 Kenichi Handa <handa@m17n.org> |
| 2 | 11 | ||
| 3 | * international/mule-diag.el (print-fontset): Handling of the | 12 | * international/mule-diag.el (print-fontset): Handling of the |
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index 12c39117ddd..07d1a54d87b 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el | |||
| @@ -226,7 +226,7 @@ Preserve the modified states of the buffers and set `buffer-swapped-with'." | |||
| 226 | "Return a `tar-header' structure. | 226 | "Return a `tar-header' structure. |
| 227 | This is a list of name, mode, uid, gid, size, | 227 | This is a list of name, mode, uid, gid, size, |
| 228 | write-date, checksum, link-type, and link-name." | 228 | write-date, checksum, link-type, and link-name." |
| 229 | (assert (<= (+ pos 512) (point-max))) | 229 | (if (> (+ pos 512) (point-max)) (error "Malformed Tar header")) |
| 230 | (assert (zerop (mod (- pos (point-min)) 512))) | 230 | (assert (zerop (mod (- pos (point-min)) 512))) |
| 231 | (assert (not enable-multibyte-characters)) | 231 | (assert (not enable-multibyte-characters)) |
| 232 | (let ((string (buffer-substring pos (setq pos (+ pos 512))))) | 232 | (let ((string (buffer-substring pos (setq pos (+ pos 512))))) |
| @@ -483,7 +483,7 @@ MODE should be an integer which is a file mode value." | |||
| 483 | (point-min) (point-max)))) | 483 | (point-min) (point-max)))) |
| 484 | descriptor) | 484 | descriptor) |
| 485 | (with-current-buffer tar-data-buffer | 485 | (with-current-buffer tar-data-buffer |
| 486 | (while (and (<= (+ pos 512) (point-max)) | 486 | (while (and (< pos (point-max)) |
| 487 | (setq descriptor (tar-header-block-tokenize pos coding))) | 487 | (setq descriptor (tar-header-block-tokenize pos coding))) |
| 488 | (let ((size (tar-header-size descriptor))) | 488 | (let ((size (tar-header-size descriptor))) |
| 489 | (if (< size 0) | 489 | (if (< size 0) |
| @@ -654,9 +654,17 @@ See also: variables `tar-update-datestamp' and `tar-anal-blocksize'. | |||
| 654 | (generate-new-buffer (format " *tar-data %s*" | 654 | (generate-new-buffer (format " *tar-data %s*" |
| 655 | (file-name-nondirectory | 655 | (file-name-nondirectory |
| 656 | (or buffer-file-name (buffer-name)))))) | 656 | (or buffer-file-name (buffer-name)))))) |
| 657 | (tar-swap-data) | 657 | (condition-case err |
| 658 | (tar-summarize-buffer) | 658 | (progn |
| 659 | (tar-next-line 0)) | 659 | (tar-swap-data) |
| 660 | (tar-summarize-buffer) | ||
| 661 | (tar-next-line 0)) | ||
| 662 | (error | ||
| 663 | ;; If summarizing caused an error, then maybe the buffer doesn't contain | ||
| 664 | ;; tar data. Rather than show a mysterious empty buffer, let's | ||
| 665 | ;; revert to fundamental-mode. | ||
| 666 | (fundamental-mode) | ||
| 667 | (signal (car err) (cdr err))))) | ||
| 660 | 668 | ||
| 661 | 669 | ||
| 662 | (defun tar-subfile-mode (p) | 670 | (defun tar-subfile-mode (p) |
| @@ -773,7 +781,13 @@ appear on disk when you save the tar-file's buffer." | |||
| 773 | (read-only-p (or buffer-read-only view-p)) | 781 | (read-only-p (or buffer-read-only view-p)) |
| 774 | (new-buffer-file-name (expand-file-name | 782 | (new-buffer-file-name (expand-file-name |
| 775 | ;; `:' is not allowed on Windows | 783 | ;; `:' is not allowed on Windows |
| 776 | (concat tarname "!" name))) | 784 | (concat tarname "!" |
| 785 | (if (string-match "/" name) | ||
| 786 | name | ||
| 787 | ;; Make sure `name' contains a / | ||
| 788 | ;; so set-auto-mode doesn't try | ||
| 789 | ;; to look at `tarname' for hints. | ||
| 790 | (concat "./" name))))) | ||
| 777 | (buffer (get-file-buffer new-buffer-file-name)) | 791 | (buffer (get-file-buffer new-buffer-file-name)) |
| 778 | (just-created nil) | 792 | (just-created nil) |
| 779 | undo-list) | 793 | undo-list) |