1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00
elinks/test
Kalle Olavi Niemitalo 25da8085b3 Fix double-free crash if EOF immediately follows </MAP>.
look_for_link() used to return 0 both when it found the closing </MAP>
tag, and when it hit the end of the file.  In the first case, it also
added *menu to the memory_list; in the second case, it did not.  The
caller get_image_map() supposedly distinguished between these cases by
checking whether pos >= eof, and freed *menu separately if so.

However, if the </MAP> was at the very end of the HTML file, so that
not even a newline followed it, then look_for_link() left pos == eof
even though it had found the </MAP> and added *menu to the memory_list.
This made get_image_map() misinterpret the result and mem_free(*menu)
even though *menu had already been freed as part of the memory_list;
thus the crash.

To fix this, make look_for_link() return -1 instead of 0 if it hits
EOF without finding the </MAP>.  Then make get_image_map() check the
return value instead of comparing pos to eof.  And add a test case,
although not an automated one.

Alternatively, look_for_link() could have been changed to decrement
pos between finding the </MAP> and returning 0.  Then, the pos >= eof
comparison in get_image_map() would have been false.  That scheme
would however have been a bit more difficult to understand and
maintain, I think.

Reported by Paul B. Mahol.
(cherry picked from commit a2404407ce)
2008-12-31 20:15:44 +00:00
..
cgi 1034: NEWS, comments, and tests 2008-07-20 14:34:12 +03:00
css Remove unclearly licensed test files. 2008-10-03 10:39:12 +03:00
docbook Although aware ELinks doesn't need another sgml/doctype here is DocBook 2006-01-01 23:22:10 +01:00
ecmascript SEE compatibility in forms.namedItem.html. 2007-06-10 15:16:51 +03:00
rss Add an RSS test file 2005-12-30 22:18:22 +01:00
server Fixed bug relating to newlines in hidden input fields 2008-11-09 23:28:46 +02:00
xbel Add basic stuff for XBEL parsing/highlighting using the DOM engine 2005-12-30 22:19:32 +01:00
backspaces.txt Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
bigtextarea.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
color.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
comments.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
garbage.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
GFDL-1.2 test/optgroup.html is under GNU Free Documentation License 2008-09-24 02:08:51 +03:00
href_tests.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
imgmap2.html Fix double-free crash if EOF immediately follows </MAP>. 2008-12-31 20:15:44 +00:00
imgmap.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
libtest.sh Move URI normalization to the test library 2006-01-28 15:03:19 +01:00
longtitle.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
malicious_uris.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
nbsp.html Bug 811: Added test/nbsp.html. 2006-10-15 13:37:27 +03:00
nocache.html Fix process_head to check for cache-control information even if no refresh 2007-09-12 23:33:40 +02:00
optgroup.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
portlink.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
README test/optgroup.html is under GNU Free Documentation License 2008-09-24 02:08:51 +03:00
refresh2.html Add a simple testcase for missing ; in meta refresh content attribute. 2007-09-14 11:56:55 +02:00
refresh.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
refresh+nocache.html Fix process_head to check for cache-control information even if no refresh 2007-09-12 23:33:40 +02:00
remote.sh Add simple script to testing the various features of the -remote option 2006-12-04 21:50:01 +01:00
subsup.html More sub/sup tests. 2005-10-19 23:05:41 +02:00
tabindex.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
tablebg.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
tables.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
target_blank.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
td-width.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
underline.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00
xmp.html Initial commit of the HEAD branch of the ELinks CVS repository, as of 2005-09-15 15:58:31 +02:00

This directory contains various weird documents for testing whether we're
parsing and rendering them properly. Frequently, documents are getting added
here when we implement feature needed for their correct presentation or fix bug
occuring inside of these documents. No automated testsuite yet, though.

Possible meaningful content of the documents is completely irrelevant and you
should ignore it. Noone takes any responsibility for it :).

optgroup.html originates from <http://iccl.fi/>.  Ari Sovijärvi kindly
granted us the "GNU free documentation licence" (included in the file
GFDL-1.2).