aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1994-10-26 01:40:21 +0000
committerKarl Heuer1994-10-26 01:40:21 +0000
commit1b15043ec25c13fd30a9862bdab7415bc8fb8a04 (patch)
treead0bc2c688f0f1fad29b09b991a91597238a9107
parenta9fde32e8d406247ed35ceceb5fa55200991020b (diff)
downloademacs-1b15043ec25c13fd30a9862bdab7415bc8fb8a04.tar.gz
emacs-1b15043ec25c13fd30a9862bdab7415bc8fb8a04.zip
(tar-summarize-buffer): Check for end of buffer before extracting substring.
-rw-r--r--lisp/tar-mode.el66
1 files changed, 33 insertions, 33 deletions
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index bddd32a12fa..190c37988b9 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -398,40 +398,40 @@ is visible (and the real data of the buffer is hidden)."
398 (pos 1) 398 (pos 1)
399 (bs (max 1 (- (buffer-size) 1024))) ; always 2+ empty blocks at end. 399 (bs (max 1 (- (buffer-size) 1024))) ; always 2+ empty blocks at end.
400 (bs100 (max 1 (/ bs 100))) 400 (bs100 (max 1 (/ bs 100)))
401 (tokens nil)) 401 (tokens nil))
402 (while (not (eq tokens 'empty-tar-block)) 402 (while (not (eq tokens 'empty-tar-block))
403 (let* ((hblock (buffer-substring pos (+ pos 512)))) 403 (if (> (+ pos 512) (point-max))
404 (setq tokens (tar-header-block-tokenize hblock)) 404 (error "premature EOF parsing tar file"))
405 (setq pos (+ pos 512)) 405 (setq tokens
406 (message "parsing tar file...%s%%" 406 (tar-header-block-tokenize (buffer-substring pos (+ pos 512))))
407 ;(/ (* pos 100) bs) ; this gets round-off lossage 407 (setq pos (+ pos 512))
408 (/ pos bs100) ; this doesn't 408 (message "parsing tar file...%d%%"
409 ) 409 ;(/ (* pos 100) bs) ; this gets round-off lossage
410 (if (eq tokens 'empty-tar-block) 410 (/ pos bs100) ; this doesn't
411 nil 411 )
412 (if (null tokens) (error "premature EOF parsing tar file")) 412 (if (eq tokens 'empty-tar-block)
413 (if (eq (tar-header-link-type tokens) 20) 413 nil
414 ;; Foo. There's an extra empty block after these. 414 (if (eq (tar-header-link-type tokens) 20)
415 (setq pos (+ pos 512))) 415 ;; Foo. There's an extra empty block after these.
416 (let ((size (tar-header-size tokens))) 416 (setq pos (+ pos 512)))
417 (if (< size 0) 417 (let ((size (tar-header-size tokens)))
418 (error "%s has size %s - corrupted" 418 (if (< size 0)
419 (tar-header-name tokens) size)) 419 (error "%s has size %s - corrupted"
420 ; 420 (tar-header-name tokens) size))
421 ; This is just too slow. Don't really need it anyway.... 421 ;
422 ;(tar-header-block-check-checksum 422 ; This is just too slow. Don't really need it anyway....
423 ; hblock (tar-header-block-checksum hblock) 423 ;(tar-header-block-check-checksum
424 ; (tar-header-name tokens)) 424 ; hblock (tar-header-block-checksum hblock)
425 425 ; (tar-header-name tokens))
426 (setq result (cons (make-tar-desc pos tokens) result)) 426
427 427 (setq result (cons (make-tar-desc pos tokens) result))
428 (if (and (null (tar-header-link-type tokens)) 428
429 (> size 0)) 429 (and (null (tar-header-link-type tokens))
430 (setq pos 430 (> size 0)
431 (+ pos 512 (ash (ash (1- size) -9) 9)) ; this works 431 (setq pos
432 ;(+ pos (+ size (- 512 (rem (1- size) 512)))) ; this doesn't 432 (+ pos 512 (ash (ash (1- size) -9) 9)) ; this works
433 )) 433 ;(+ pos (+ size (- 512 (rem (1- size) 512)))) ; this doesn't
434 )))) 434 )))))
435 (make-local-variable 'tar-parse-info) 435 (make-local-variable 'tar-parse-info)
436 (setq tar-parse-info (nreverse result))) 436 (setq tar-parse-info (nreverse result)))
437 (save-excursion 437 (save-excursion