simon-git: puzzles (main): Ben Harris

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sun Apr 9 16:59:44 BST 2023


TL;DR:
  e411db7 Net: assert that cx and cy are in range in compute_active()
  418cb3a Make encode_ui() and decode_ui() optional in back-ends
  9be7db5 Add a game_state argument to decode_ui()
  a4c6f21 Net: validate co-ordinates in decode_ui()
  71cf891 Don't allow zero clues in Pattern

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer:      Ben Harris <bjh21 at bjh21.me.uk>
Date:           2023-04-09 16:59:44

commit e411db788cfc0d0ed54b3c9b9deb15edba7d237a
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=e411db788cfc0d0ed54b3c9b9deb15edba7d237a;hp=d505f08f671c2f0a3fdd0b7d733e4ce987aa4786
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Mon Feb 13 22:14:26 2023 +0000

    Net: assert that cx and cy are in range in compute_active()
    
    This avoids an out-of-range heap write shortly afterwards.  An assertion
    failure is better than a buffer overrun, but still not ideal.  Fixing
    the problem properly will require fairly wide-ranging changes, though.
    
    The bug can be demonstrated by loading this save file into a build with
    AddressSanitizer:
    
    SAVEFILE:41:Simon Tatham's Portable Puzzle Collection
    VERSION :1:1
    GAME    :3:Net
    PARAMS  :4:5x5w
    CPARAMS :4:5x5w
    DESC    :25:9893e85285bb72e6de5182741
    UI      :9:O0,0;C6,6
    NSTATES :1:1
    STATEPOS:1:1

 net.c | 2 ++
 1 file changed, 2 insertions(+)

commit 418cb3a5671404d2d91bf221887df2be2ae2654f
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=418cb3a5671404d2d91bf221887df2be2ae2654f;hp=e411db788cfc0d0ed54b3c9b9deb15edba7d237a
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Mon Feb 13 22:41:40 2023 +0000

    Make encode_ui() and decode_ui() optional in back-ends
    
    The majority of back-ends define encode_ui() to return NULL and
    decode_ui() to do nothing.  This commit allows them to instead specify
    the relevant function pointers as NULL, in which case the mid-end won't
    try to call them.
    
    I'm planning to add a parameter to decode_ui(), and if I'm going to have
    to touch every back-end's version of decode_ui(), I may as well ensure
    that most of them never need to be touched again.  And obviously
    encode_ui() should go the same way for symmetry.

 bridges.c             | 13 ++-----------
 cube.c                | 13 ++-----------
 devel.but             |  6 ++++++
 dominosa.c            | 13 ++-----------
 fifteen.c             | 13 ++-----------
 filling.c             | 13 ++-----------
 flip.c                | 13 ++-----------
 flood.c               | 13 ++-----------
 galaxies.c            | 13 ++-----------
 keen.c                | 13 ++-----------
 lightup.c             | 15 ++-------------
 loopy.c               | 13 ++-----------
 magnets.c             | 13 ++-----------
 map.c                 | 13 ++-----------
 midend.c              |  4 ++--
 mosaic.c              | 13 ++-----------
 netslide.c            | 13 ++-----------
 nullgame.c            | 13 ++-----------
 palisade.c            | 13 ++-----------
 pattern.c             | 13 ++-----------
 pearl.c               | 13 ++-----------
 pegs.c                | 13 ++-----------
 range.c               | 13 ++-----------
 rect.c                | 13 ++-----------
 samegame.c            | 13 ++-----------
 signpost.c            | 13 ++-----------
 singles.c             | 13 ++-----------
 sixteen.c             | 13 ++-----------
 slant.c               | 13 ++-----------
 solo.c                | 13 ++-----------
 tents.c               | 13 ++-----------
 towers.c              | 13 ++-----------
 tracks.c              | 13 ++-----------
 twiddle.c             | 13 ++-----------
 undead.c              | 14 ++------------
 unequal.c             | 13 ++-----------
 unfinished/group.c    | 13 ++-----------
 unfinished/separate.c | 13 ++-----------
 unfinished/slide.c    | 13 ++-----------
 unfinished/sokoban.c  | 13 ++-----------
 unruly.c              | 13 ++-----------
 untangle.c            | 13 ++-----------
 42 files changed, 88 insertions(+), 445 deletions(-)

commit 9be7db547aa2eba68492dc3326ea36ebeeb63505
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=9be7db547aa2eba68492dc3326ea36ebeeb63505;hp=418cb3a5671404d2d91bf221887df2be2ae2654f
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Mon Feb 13 23:22:59 2023 +0000

    Add a game_state argument to decode_ui()
    
    Some games would like a way to check that the parameters in the encoded
    UI string are consistent with the game parameters.  Since this might
    depend on the current state of the game (this being what changed_state()
    is for), implement this by adding a game_state parameter to decode_ui().
    Nothing currently uses it, though Guess usefully could.

 blackbox.c | 3 ++-
 devel.but  | 7 +++++--
 guess.c    | 3 ++-
 inertia.c  | 3 ++-
 midend.c   | 3 ++-
 mines.c    | 3 ++-
 net.c      | 3 ++-
 puzzles.h  | 3 ++-
 8 files changed, 19 insertions(+), 9 deletions(-)

commit a4c6f21b8e286322d3c1820785907a000fe1092f
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=a4c6f21b8e286322d3c1820785907a000fe1092f;hp=9be7db547aa2eba68492dc3326ea36ebeeb63505
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Tue Feb 14 00:06:10 2023 +0000

    Net: validate co-ordinates in decode_ui()
    
    The offset and centre location should be within the grid.  Otherwise the
    redraw code will suffer an assertion failure.  This save file
    demonstrates the problem:
    
    SAVEFILE:41:Simon Tatham's Portable Puzzle Collection
    VERSION :1:1
    GAME    :3:Net
    PARAMS  :4:5x5w
    CPARAMS :4:5x5w
    DESC    :25:9893e85285bb72e6de5182741
    UI      :9:O0,0;C6,6
    NSTATES :1:1
    STATEPOS:1:1

 net.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

commit 71cf891fdc3ab237ecf0e5d1aae39b6c9fe97a4d
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=71cf891fdc3ab237ecf0e5d1aae39b6c9fe97a4d;hp=a4c6f21b8e286322d3c1820785907a000fe1092f
Author: Ben Harris <bjh21 at bjh21.me.uk>
Date:   Tue Feb 14 13:16:53 2023 +0000

    Don't allow zero clues in Pattern
    
    Some nonogram implementations allow zero clues so that a row or column
    with a single zero clue is equivalent to one with no clues, that is it
    has no black squares in it.  Pattern, however, doesn't interpret them
    like this and treats a puzzle with a zero clue as insoluble, so it's
    not helpful to permit them.
    
    Permitting zero clues also confuses Pattern's memory allocation so
    that it can suffer a buffer overrun.  As an example, before this
    commit a build with AddressSanitizer would report a buffer overrun
    with the description "1:0/0.0" because it tries to put two clues in a
    row that can have a maximum of one.

 pattern.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)



More information about the tartarus-commits mailing list