Commit graph

5097 commits

Author SHA1 Message Date
4bce12ac0b travis: Enable OS X
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:39 +01:00
42a3c10fd9 navigate march: Fix abort not to wipe out concurrent updates
When the player aborts the command at the movement prompt, we write
back stale ships or land units, triggering a generation oops.  Any
updates made by other threads meanwhile are wiped out, triggering a
seqno mismatch oops.

Broken in commit 24000b4, v4.3.33.  Fix by restoring the lost
shp_nav_stay_behind() and lnd_mar_stay_behind() calls.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:39 +01:00
354b6aea3d tests/navi-march: Cover abort at movement prompt
This exposes generation oopses.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:39 +01:00
863fde5a2c march: Fix concurrent updates at sector abandon prompt
When the player declines to abandon a sector, we write back stale land
units, triggering a generation oops.  Any updates made by other
threads meanwhile are wiped out, triggering a seqno mismatch oops.

The culprit is lnd_abandon_askyn(): when the player declines, it
returns without calling check_sect_ok(), check_land_ok().  Broken in
commit 7c1b166, v4.3.33.  Fix it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:38 +01:00
8daeffbd8f recvclient: Track potential yield on input
recvclient() calls ef_make_stale() only when it does actual I/O, via
io_output() and io_input().  Missed in commit 2fa5f652, v4.3.24.  Call
it directly when it doesn't do actual I/O.

This makes navi-march-test expose a bug in march: when the player
declines to abandon a sector, we write back stale land units,
triggering a generation oops.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:38 +01:00
9645caf6ff configure: Use -fstack-protector-strong when available
Testing whether the compiler supports it is a bit tricky.

The obvious AX_APPEND_COMPILE_FLAGS([-fstack-protector-strong])
doesn't suffice, since some ports of the GNU toolchain reportedly pass
this test, then fail to link.  That's because the compiler accepts the
flag, duly emits references to helper code in libc, but libc doesn't
provide, and linking fails.

Instead, use AX_APPEND_LINK_FLAGS with an input source that makes the
compiler emit the extra stack checking code.  This requires the latest
version from the autoconf-archive, so update m4/ax* to commit e3d948b.
Also update m4/my_append_compile_flags.m4 to keep it in sync with
upstream's ax_append_compile_flags.m4.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:38 +01:00
41263cf8c9 scripts/savecore: Report nicely when there's no core dump
When savecore can't find a core dump, it reports something like

    ls: cannot access core.*: No such file or directory

to stderr, and fails.  If privlog is set, it also mails out a "Could
not save core dump" note.

Suppress the error message, and mail out "Could not find core dump to
save" instead.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:38 +01:00
3f86dd2ecf configure: Use -fno-strict-aliasing -fno-strict-overflow
Contemporary compilers can squeeze out some extra performance by
assuming the program never executes code that has undefined behavior
according to the C standard.  Unfortunately, this can break programs.
Pointing out that these programs are non-conforming is as correct as
it is unhelpful, at least as long as the compiler is unable to
diagnose the non-conformingness.

Since keeping our programs working is a lot more important to us than
running them as fast as possible, forbid some assumptions that are
known to break real-world programs:

* Aliasing: perfectly clean programs don't engage in type-punning, and
  perfectly conforming programs do it only in full accordance with the
  standard's (subtle!) aliasing rules.  Neither kind of perfection is
  realistic for us, therefore -fno-strict-aliasing.

* Signed integer overflow: perfectly clean programs won't ever do
  signed integer arithmetic that overflows.  This is an imperfect
  program, therefore -fno-strict-overflow.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:19:38 +01:00
6e80cf103f tests: Enable GNU libc memory allocation error checking
MALLOC_CHECK_=3 makes glibc check for memory allocation programming
errors.  It's the factory default, but set it anyway just in case
someone disabled it for speed.

Non-zero MALLOC_PERTURB_ makes glibc wipe memory value on allocation
and deallocation.  The actual value determines the bit pattern.  Set
it to the value of environment variable EMPIRE_CHECK_MALLOC_PERTURB or
else a pseudo-random number, and record it in sandbox/malloc-perturb.

See mallopt(3) for more information.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 13:03:08 +01:00
1abd3c5b0b navigate march: Plug memory leaks
When the player aborts the command at the movement prompt, or declines
to abandon a sector, unit_move() returns without freeing the list.
Found with valgrind.  Broken in commit 24000b4 and commit 7c1b166,
both v4.3.33.

Free the list on these returns, too.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:51:07 +01:00
25c7d3798b navigate march retreat lretreat: Fix read beyond buffer
shp_nav_gauntlet() and lnd_mar_gauntlet() read beyond the list head
when the list is empty.  The values read aren't used then.  Could
conceivably crash the server anyway, but it's unlikely.

Empty list happens when shp_nav_dir(), lnd_mar_dir() empty the list
and return zero.  Broken in commit beedf8d, v4.3.33.  Occurs in
navi-march-test (since the last commit) and in retreat-test.

Change shp_nav_dir() and lnd_mar_dir() to return one then.  For
additional safety, make shp_nav_gauntlet() and lnd_mar_gauntlet() oops
on empty list and recover safely.

I think I originally found this bug with -fsanitize, but I've since
upgraded, and I can't diagnose it that way anymore.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:51:07 +01:00
493dc5f941 tests/navi-march: Cover running out of mobility completely
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:51:07 +01:00
6888337afe bomb drop fly paradrop recon sweep: Fix read before array
The code computing the length of the flight path checks whether the
path ends with 'h'.  When getpath() returns an empty path, it accesses
flightpath[-1].  This could set the length to -1 (unlikely), or crash
(even less likely).  The former could be abused to gain mobility for
sufficiently inefficient or short-ranged planes.  Found with valgrind.

Broken in commit 404a76f7, v4.3.27.

Historically, getpath() could return paths with or without 'h', and
the check was necessary.  It returned an empty path only when the
player gave no input, aborting the command.  When the player entered
the assembly point's coordinates, it returned "h".

Commit 404a76f7 accidentally changed it to return "" then.  Also broke
flying to the assembly point's coordinates.  Commit 0f1e14f (v4.3.31)
fixed that part by changing getpath()'s contract: always return paths
without 'h' ("" simply means empty path), and return NULL on invalid
input, including no input.

The flawed check is superfluous since then.  Drop it.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:51:07 +01:00
b9375b14b1 Avoid shifting into sign bit
It's undefined behavior.  Found with gcc -fsanitize=undefined.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:50:54 +01:00
d58bea5458 Convert run-time to build-time assertion
There's just one, in show_product().

Use new BUILD_ASSERT() there, because its contract is even simpler
than BUILD_ASSERT_ONE()'s.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:43:28 +01:00
80bf4ec34b Provide proper build-time assertions for NSC_SITYPE()
We want to cause a diagnostic when NSC_SITYPE()'s argument isn't
implemented.  Commit aa6ad9d's solution is to have the macro expand
into 1/0 then.  Works with GCC, but Clang always warns "division by
zero is undefined".

The better, portable way to conditionally break the build is an array
type with a size that's negative when the build should fail, else
positive.  Implement that wrapped in a sizeof() to make it an
expression as macro BUILD_ASSERT_ONE(), and use it in NSC_SITYPE().

No more warnings from Clang 3.5.0.  GCC still produces its "may be
used uninitialized" false positives.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:42:40 +01:00
d074d29736 subs: Don't squash telegrams together when time goes backwards
We've always squashed them when the time difference is smaller than
TEL_SECONDS, regardless of sign.  This involves passing the difference
to abs(), implicitly casting from time_t to int, which triggers a
Clang warning.

I could clean this up to get rid of the warning, but time should never
go backwards, and trying to make things prettier when it does isn't
worthwhile.  Simply drop the abs().

While there, drop the function comment.  It's been inaccurate since
Empire 3 dropped mail.c, and bogus since commit 17223e8 (v4.3.29)
added tel_cont.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
feb894cf1e info/Nuke-types: Document show columns avail, res, abilities
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
659957c40c info/Unit-types: Belatedly remove capability xlight
L_XLIGHT was replaced in commit e28c14f, v4.3.0.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
c0b41650c5 info/Plane-types: Belatedly remove stealth and half-stealth
P_X and P_H were removed in commit 61233e4, v4.3.23.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
6787049ae5 info/Ship-types: Belatedly remove capability spy
M_SPY was removed in commit 498d9fb, v4.3.0.  It never did anything.

Reported-by: Harald Katzer
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
5010240995 info: Belatedly update for change of stop prefix to '!'
Commit eb1512d (v4.3.6) added the '=' if stopped before efficiency.
Commit 016249c (v4.3.6) changed it to '!' without updating info ship,
plane, land, nuke.

Reported-by: Harald Katzer
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
b031770040 info/version: Update example to current output
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:16 +01:00
58a6e7270f info: Fix option NOMOBCOST misinformation
The cost of firing naval guns is 15 mobility with option NOMOBCOST
disabled.  Mobility.t is correct.

Fix Options.t not to claim submarines pay half the sector movement
cost when NOMOBCOST is enabled.

Fix fire.t not to claim ships pay half the sector movement cost when
NOMOBCOST is disabled.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:15 +01:00
00abc9616d info/Options: Nicer markup, more consistent format
Don't list options separately for major server versions.  It's only of
historical interest, which "info History" satisfies.

Make it a list (.L) instead of preformatted text (.nf).

Fix up so the option explanations are full sentences, starting with a
capital letter and ending with a period.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:15 +01:00
b1525ef272 info/Options: Belatedly remove SAIL
Missed in commit dc73207.

Reported-by: Harald Katzer
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:15 +01:00
6986ac4778 lwp: Rename LwpSigCatched to LwpSigCaught
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:15 +01:00
6b6708a01b docs/coding: Explain function/struct/union comment conventions
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:41:15 +01:00
eba87789ab Fix and clean up some comments
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:31:08 +01:00
9f25de3dce Change comment style to use @foo rather than FOO
... when referring to a function's parameter or a struct/union's
member.

The idea of using FOO comes from the GNU coding standards:

    The comment on a function is much clearer if you use the argument
    names to speak about the argument values.  The variable name
    itself should be lower case, but write it in upper case when you
    are speaking about the value rather than the variable itself.
    Thus, "the inode number NODE_NUM" rather than "an inode".

Upcasing names is problematic for a case-sensitive language like C,
because it can create ambiguity.  Moreover, it's too much shouting for
my taste.

GTK-Doc's convention to prefix the identifier with @ makes references
to variables stand out nicely.  The rest of the GTK-Doc conventions
make no sense for us, however.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:13:17 +01:00
5cff5022a9 configure: Suppress Clang warning on carg()
Renaming carg() would be smarter, but I'd rather do that as part of a
consistent renaming of all command functions, and I'm not up to that
right now.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:11:37 +01:00
b824134240 configure: Enable -Wformat-security
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:11:37 +01:00
b34cbad683 pr: Make prdate() more obviously correct
Using ctime() as pr()'s first argument is safe, because its value
never contains '%'.  Clean it up anyway, so we can enable
-Wformat-security.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:11:37 +01:00
d9837728c2 configure: Enable more gcc warnings
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-12-05 12:11:37 +01:00
23373d01d9 configure: Test compiler flags
When AC_PROG_CC detects GCC, Make.mk adds a bunch of flags to CFLAGS.
Works only for flags that any version of gcc in use accepts.

Instead, make configure add the flags that actually work to CFLAGS.
This will let us add flags that work only for some compilers.

The new autoconf macros are from autoconf-archive v2015.02.24.

Unfortunately, AX_APPEND_COMPILE_FLAGS doesn't work reliably for
-Wno-*: gcc complains about unknown -Wno-foo only when other
diagnostics are being produced.  Test -Wfoo instead of -Wno-foo, and
rename to MY_APPEND_COMPILE_FLAGS.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-11-22 10:23:54 +01:00
35f34581be configure: Drop unused AC_C_CHAR_UNSIGNED test
Unused since commit 0c8c169. v4.3.3.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-06-06 15:49:28 +02:00
87d08a4584 Bump version to 4.3.34
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-06-04 10:52:11 +02:00
00985535de Update change log timestamp for 4.3.33
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-20 20:20:40 +02:00
fff177be2f Revert "commands: Always put ship or land unit before retreating it"
This reverts commit f4d8d64bb3.

Breaks retreat after ship got sunk by bombs or missile.

ship_bomb() and launch_missile() pass .shp_own to retreat_ship().
Wrong after putship(), because putship() resets the owner when the
ship got sunk.  retreat_ship() then oopses and fails to retreat the
surviving members of the group.

Other callers save the owner before putting the ship, and pass that.
We could change these two to do the same.  But since we're trying to
get a release out, simply revert the broken commit instead.
2015-05-17 18:11:20 +02:00
1c9fb831ed Tidy up some comments
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-17 18:08:45 +02:00
5b9b4c3c89 Update change log again for 4.3.33
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-14 09:49:12 +02:00
341b1b4d15 Improve portability to really outmoded compilers
A few modernisms have crept in:

* Trailing comma in enum definition (commit 71320ed, v4.3.10)

* // comment (commit 265e71e, v4.3.11)

* <stdint.h> (commit 9102ecc, v4.3.31)

  MSC actually chokes on this one.

Avoid them.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-14 09:48:57 +02:00
7f68f37433 xundump: Pass unsigned * for scanf directive %3o, not int *
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-14 09:48:57 +02:00
a96c43c723 rdsched: Pass unsigned * for scanf directive %u, not int *
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-14 09:48:57 +02:00
05fe8b771c info/History: Cover removal of Autonav, SAIL and TREATIES
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-14 09:48:35 +02:00
a455169edd w32/strptime: Fix for 64 bit pointers
The __UNCONST() stolen from NetBSD assumes unsigned long can hold a
pointer.  Not true with Win64's LLP64 data model.  There, we cast the
64 bit pointer to 32 bits and back.  Works only because Windows puts
the stack at a very low address, and the casts don't actually change
the pointer.

Dumb it down to a straight cast to void * for safety.

Thanks to Harald Katzer and Ron Koenderink for their help figuring out
the bug's impact.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-05-14 09:39:19 +02:00
953ff83fb1 Update change log again for 4.3.33
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-13 07:07:03 +01:00
884dd4d532 INSTALL: Refresh from automake 1.13
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-08 18:23:33 +01:00
64f32cde53 man: Get rid of unwanted space in SYNOPSIS
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-08 17:48:17 +01:00
Marisa Giancarla
0a6eb70b28 client: New option -r for restricted mode
Redirections and the execute command let the user read and write files
and run programs on the local system.

Restricted mode prevents such access.  This is useful when you want to
grant somebody access to just Empire, but not to the host system's
user account that runs the client.

Signed-off-by: Marisa Giancarla <fstltna@me.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
2015-03-08 17:30:46 +01:00