Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old August 13, 2010, 22:10   #1
jbu
Rookie
 
Join Date: Jul 2010
Posts: 9
jbu is on a distinguished road
Bad memory read

fwiw I just found a bad memory read in spells2.c

Code:
void map_area(void)
{
	int i, x, y;
	int x1, x2, y1, y2;

	/* Pick an area to map */
	y1 = p_ptr->py - DETECT_DIST_Y;
	y2 = p_ptr->py + DETECT_DIST_Y;
	x1 = p_ptr->px - DETECT_DIST_X;
	x2 = p_ptr->px + DETECT_DIST_X;

	if (y1 < 0) y1 = 0;
	if (x1 < 0) x1 = 0;

	/* Scan the dungeon */
	for (y = y1; y < y2; y++)
	{
		for (x = x1; x < x2; x++)
		{
			/* All non-walls are "checked" */
			if (cave_feat[y][x] < FEAT_SECRET)
			{
				if (!in_bounds_fully(y, x)) continue;
                                //stuff
Now, there is no check on the outer bounds for x2 and y2 and they might (will) exceed the borders of cave_feat. The in_bounds_fully() check is done after the read. A fix is to move that check to the start of the loop or just restrict the loop upper bounds.

Cheers
jbu is offline   Reply With Quote
Old August 14, 2010, 14:57   #2
ajps
Apprentice
 
Join Date: May 2007
Location: Manchester, UK
Posts: 50
ajps is on a distinguished road
Quote:
Originally Posted by jbu View Post
Now, there is no check on the outer bounds for x2 and y2 and they might (will) exceed the borders of cave_feat. The in_bounds_fully() check is done after the read. A fix is to move that check to the start of the loop or just restrict the loop upper bounds.
I've done the latter of those in r2039 (untested code, but it's not that complicated). Thanks for reporting!
ajps is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The Official Bad Advice Thread steeg1234321 Vanilla 158 October 24, 2011 19:56
Selling bad weapons z118 Vanilla 10 February 14, 2010 12:02
Mark everything read? Timo Pietilš Oook! 5 November 30, 2009 16:05
rPoison (please read as ARR Poison) Sergio Vanilla 28 August 28, 2009 03:34
Equipment? And how bad is aggravation? fmackenz Vanilla 3 November 1, 2008 10:21


All times are GMT +1. The time now is 18:01.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.