diff options
-rw-r--r-- | crawl-ref/source/AppHdr.h | 25 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 14 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/spells1.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/spells2.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/spells4.cc | 2 |
7 files changed, 52 insertions, 12 deletions
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h index 3c91b2ef07..e1cbba9582 100644 --- a/crawl-ref/source/AppHdr.h +++ b/crawl-ref/source/AppHdr.h @@ -402,17 +402,38 @@ // // PACKAGE_SUFFIX is used when the package file name is needed // + +/* + FIXME: Unless sanitized elsewhere in the codebase, a specially crafted + save directory or character name will allow arbitrary code execution + with escalated privileges (namely, with group "games"). + FIXME: replace system(3) with fork(2) and execve(2). +*/ + // Comment these lines out if you want to leave the save files uncompressed. + #define SAVE_PACKAGE_ZIP +// #define SAVE_PACKAGE_TAR + +#ifdef SAVE_PACKAGE_ZIP + #define PACKAGE_SUFFIX ".zip" #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j -1 %s.zip %s.*" #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d %s" +#else +#ifdef SAVE_PACKAGE_TAR + #define PACKAGE_SUFFIX ".tgz" + + // The --absolute-names switch is only there to suppress noise on + // stdout. All the paths are removed later by --transform. + #define SAVE_PACKAGE_CMD "tar -zcf %s.tgz --remove-files --absolute-names --transform=s:.*/:: %s.*" + #define LOAD_UNPACKAGE_CMD "tar -zxf %s.tgz -C %s" +#endif +#endif #ifdef SAVE_PACKAGE_CMD // This is used to unpack specific files from the archive. #define UNPACK_SPECIFIC_FILE_CMD LOAD_UNPACKAGE_CMD " %s" #endif - #define PACKAGE_SUFFIX ".zip" - // This defines the chmod permissions for score and bones files. #define SHARED_FILES_CHMOD_PRIVATE 0664 #define SHARED_FILES_CHMOD_PUBLIC 0664 diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 0edf5d15a0..6f9739d703 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1793,18 +1793,21 @@ static bool _dispersal_hit_victim(bolt& beam, actor* victim, int dmg, int tries = 0; do { - if (!random_near_space(victim->pos(), pos, false, true, no_sanct)) + if (!random_near_space(victim->pos(), pos, false, true, false, + no_sanct)) + { return (false); - } while (!victim->is_habitable(pos) && tries++ < 100); + } + } + while (!victim->is_habitable(pos) && tries++ < 100); if (!victim->is_habitable(pos)) return (false); tries = 0; do - { - random_near_space(victim->pos(), pos2, false, true, no_sanct); - } while (!victim->is_habitable(pos2) && tries++ < 100); + random_near_space(victim->pos(), pos2, false, true, false, no_sanct); + while (!victim->is_habitable(pos2) && tries++ < 100); if (!victim->is_habitable(pos2)) return (false); diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 3ab36fd41f..47845a0c19 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2471,7 +2471,7 @@ static void _set_random_slime_target(monsters* mon) // restrict_LOS: restrict target to be within PLAYER line of sight. bool random_near_space(const coord_def& origin, coord_def& target, bool allow_adjacent, bool restrict_LOS, - bool forbid_sanctuary) + bool forbid_dangerous, bool forbid_sanctuary) { // This might involve ray tracing (via num_feats_between()), so // cache results to avoid duplicating ray traces. @@ -2517,6 +2517,18 @@ bool random_near_space(const coord_def& origin, coord_def& target, continue; } + // Don't pick grids that contain a dangerous cloud. + if (forbid_dangerous) + { + const int cloud = env.cgrid(target); + + if (cloud != EMPTY_CLOUD + && is_damaging_cloud(env.cloud[cloud].type, true)) + { + continue; + } + } + if (!trans_wall_block && !origin_is_player) return (true); diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h index 24e3e40494..22619313f9 100644 --- a/crawl-ref/source/monstuff.h +++ b/crawl-ref/source/monstuff.h @@ -131,6 +131,7 @@ bool monster_blink(monsters *monster, bool quiet = false); * *********************************************************************** */ bool random_near_space(const coord_def& origin, coord_def& target, bool allow_adjacent = false, bool restrict_LOS = true, + bool forbid_dangerous = true, bool forbid_sanctuary = false); diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index c0cb9fe8aa..8e74d8f7e6 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -498,7 +498,7 @@ void identify(int power, int item_slot) // Returns whether the spell was actually cast. bool conjure_flame(int pow, const coord_def& where) { - // FIXME: this would be better handled by a flag to enforce max range. + // FIXME: This would be better handled by a flag to enforce max range. if (grid_distance(where, you.pos()) > spell_range(SPELL_CONJURE_FLAME, pow, true) || !in_bounds(where)) @@ -515,7 +515,10 @@ bool conjure_flame(int pow, const coord_def& where) if (grid_is_solid(where)) { - mpr("You can't ignite solid rock!"); + if (grd(where) == DNGN_WAX_WALL) + mpr("The flames aren't hot enough to melt wax walls!"); + else + mpr("You can't ignite solid rock!"); return (false); } diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 1a875dee08..9441008998 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -1692,7 +1692,7 @@ bool cast_conjure_ball_lightning(int pow, god_type god) bool found = false; for (int j = 0; j < 10; ++j) { - if (random_near_space(you.pos(), target, true, true) + if (random_near_space(you.pos(), target, true, true, false) && distance(you.pos(), target) <= 5) { found = true; diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index e59ebe9d88..50173cae75 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1937,7 +1937,7 @@ static int _quadrant_blink(coord_def where, int pow, int, actor *) // walls nearby. coord_def target; bool found = false; - for ( int i = 0; i < (pow*pow) / 500 + 1; ++i ) + for (int i = 0; i < (pow*pow) / 500 + 1; ++i) { // Find a space near our base point... // First try to find a random square not adjacent to the basepoint, |