[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: oneline patch to ~/.emacs.d/elpa/w3m-20190222.738/w3m-favicon.el



On 2019-02-25 15:28, rrandresf@xxxxxxxxx wrote:
> Then on some sites I am getting an "out of range" error.
>
> so I have added this line to the function
> --8<---------------cut here---------------start------------->8---
> (defun w3m-favicon-convert (data type)
>   "Convert the favicon DATA in TYPE to the favicon image and return it."
> +  (when (> (length data) 0)
>   (when (or (not (eq type 'ico))
> --8<---------------cut here---------------end--------------->8---
>
> And obviously. You would need to add the closing parentheses at the end.
>
> Perhaps someone could add that simple patch or elaborate a better
> version of the patch.

Thanks Andres,

I've prepared a patch and github pull request that changes the `when'
function to explicitly make the two required bounds checks.

  (when (or (not (eq type 'ico))
	    ;; Is it really in the ico format?
	    (and (>= (length data) 4)
                 (string-equal "\x00\x00\x01\x00" (substring data 0 4)))
	    ;; Some icons named favicon.ico are animated GIFs.
	    (and (>= (length data) 5)
                 (member (substring data 0 5) '("GIF87" "GIF89"))
		 (setq type 'gif)))


-- 
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0