Bug 206771 - games/taipan: Subscript out of bounds.
Summary: games/taipan: Subscript out of bounds.
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Jason Unovitch
URL:
Keywords: needs-patch, patch
Depends on:
Blocks:
 
Reported: 2016-01-31 02:12 UTC by Dave Walton
Modified: 2016-04-10 01:29 UTC (History)
3 users (show)

See Also:
junovitch: merge-quarterly+


Attachments
Patch for taipan.c (561 bytes, patch)
2016-01-31 10:24 UTC, c.brinkhaus
no flags Details | Diff
Patch of taipan.c by make makepatch (555 bytes, patch)
2016-01-31 11:56 UTC, c.brinkhaus
no flags Details | Diff
The LICENSE is added (331 bytes, patch)
2016-01-31 12:04 UTC, c.brinkhaus
no flags Details | Diff
Poudriere FreeBSD 10.3-PRERELEASE amd64 (10.60 KB, text/plain)
2016-01-31 12:07 UTC, c.brinkhaus
no flags Details
svn diff of patch-taipan.c (828 bytes, patch)
2016-01-31 20:48 UTC, c.brinkhaus
no flags Details | Diff
patch of taipan.c against svn (555 bytes, patch)
2016-02-03 20:17 UTC, c.brinkhaus
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Walton 2016-01-31 02:12:29 UTC
Greetings,
I was the original submitter of this port way back in 2002, and included a patch to correct a bug in the original code.  Just now I was compiling that code again and noticed another bug which I had missed back then.  Around line 2706 of taipan.c, we see:

      hkw_[0]      = 0;
      hkw_[1]      = 0;
      hkw_[3]      = 0;
      hkw_[4]      = 0;

That last subscript is out of bounds.  
The subscripts in those lines should be 0, 1, 2, 3.

Could someone update files/patch-taipan.c to fix the subscripts too?

Thanks,
Dave
Comment 1 c.brinkhaus 2016-01-31 10:24:49 UTC
Created attachment 166331 [details]
Patch for taipan.c

Please copy the patch to /usr/ports/games/taipan/files,
Apply the patch and check the file taipan.c.
Please verify if the game works as expected.
I have made the patch file only.

Kind regards,
Christoph
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-31 10:28:23 UTC
@Christoph,

Could you generate a patch against the port head using `make makepatch` please?

Instructions can be found here: https://www.freebsd.org/doc/en/books/porters-handbook/slow-patch.html

Also this port does not have a maintainer, so confirmation of passing QA (portlint, poudriere) will help it make progress
Comment 3 c.brinkhaus 2016-01-31 10:44:59 UTC
@Kubilay,
Yes, I will do that.
Comment 4 c.brinkhaus 2016-01-31 11:56:42 UTC
Created attachment 166336 [details]
Patch of taipan.c by make makepatch

Please find attached the patch using make makepatch.
Comment 5 c.brinkhaus 2016-01-31 12:04:36 UTC
Created attachment 166337 [details]
The LICENSE is added

Dear Kubilay,
I am not sure if the attachment counts as patch because it is related to /usr/ports/games/taipan/Makefile.
portlint -C reported a missing license information. I took the information from
http://www.gtlib.gatech.edu/pub/Linux/games/textrpg/taipan-0.9.lsm
which claims GPL.

# portlint -C /usr/ports/games/taipan
WARN: Consider to set DEVELOPER=yes in /etc/make.conf
0 fatal errors and 1 warning found.

I have just chosen -C because pedantic sounds good.
Comment 6 c.brinkhaus 2016-01-31 12:07:40 UTC
Created attachment 166338 [details]
Poudriere FreeBSD 10.3-PRERELEASE amd64

Dear Kubilay,

please find attached the poudriere log file.

Kind regards,
Christoph
Comment 7 c.brinkhaus 2016-01-31 12:22:13 UTC
I think I have made a mistake by adding the LICENSE information after poudriere. Now there is an error message as

---End make.conf---
=======================<phase: check-sanity   >============================
===>  taipan-0.9_1 License GPL needs confirmation, but BATCH is defined.
*** Error code 1

I will try to fix this.
Comment 8 c.brinkhaus 2016-01-31 13:27:03 UTC
Dear Kubilay,
when I change the license information from GPL to GPLv1 or GPLv2 poudriere works. The relavant part in the log seems to be
---End make.conf---
=======================<phase: check-sanity   >============================
===>  License GPLv1 accepted by the user
===========================================================================
=======================<phase: pkg-depends    >============================
===>   taipan-0.9_1 depends on file: /usr/local/sbin/pkg - not found
===>   Installing existing package /packages/All/pkg-1.6.3.txz


I have only seen textproc/aft and dns/bundy with GPL-only, but then GPL appears in LICENSE_GROUPS. Their LICENSE definitions are is CART and ISC.

It seems to be necessary to use either GPLv1, GPLv2 or not to specify LICENSE.

How to proceed?

Kind regards,
Christoph
Comment 9 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-31 16:07:23 UTC
Thanks Christoph :)

Could you run the diff against the port directory itself (after make makepatch generates the files/patch-blah file)

The easiest way to do this is to:

* Checkout the ports tree using svn (if you haven't already)
* run `make patch`
* make your extra (new) source change
* run 'make makepatch'

These steps will produces a 'new' version of current files/patch-taipan.c file

* run svn diff > taipan-patch.diff in the port dir
* Attach taipan-patch.diff here :)

In summary, all changes to the port (including updating the existing patch in files/ should be in one attachment, as a 'diff against the port'

Jump in #freebsd-ports on freenode IRC if you have any questions :)
Comment 10 Kubilay Kocak freebsd_committer freebsd_triage 2016-01-31 16:12:05 UTC
(In reply to c.brinkhaus from comment #8)

This is correct, LICENSE= takes values that are defined in /usr/ports/Mk/bsd.licenses.db.mk

'GPL' is ambiguous, which is why there are granular and version-specific values
Comment 11 c.brinkhaus 2016-01-31 20:48:32 UTC
Created attachment 166366 [details]
svn diff of patch-taipan.c

Dear Kubilay,

please find attached the diff based on the svn repository.
https://www.freshports.org/misc/py-spdx-lookup/
did not found any license information. Therefore I left
the Makefile untouched.

Kind regards,
Christoph
Comment 12 c.brinkhaus 2016-02-03 20:17:15 UTC
Created attachment 166525 [details]
patch of taipan.c against svn

I have tried to contact the author regarding the license but the mail could not be delivered. Therefore I have kept the Makefile without license entry as it is. 

The output of portlint -A is
WARN: Makefile: for new port, make $FreeBSD$ tag in comment section empty, to make SVN happy.
WARN: Makefile: new ports should not set PORTREVISION.
WARN: Makefile: new ports should not be maintained by ports@FreeBSD.org.
WARN: Makefile: Consider defining LICENSE.
WARN: Consider to set DEVELOPER=yes in /etc/make.conf
0 fatal errors and 5 warnings found.

Poudiere is still happy. Please find attached the current patch for taipan.c. In the last one I have had a stale taipan.c.orig. I am sorry for that. By the way, I have seen in the output of "make makepatch" that the original taipan.c is from 2001.
Comment 13 commit-hook freebsd_committer freebsd_triage 2016-04-10 01:22:44 UTC
A commit references this bug:

Author: junovitch
Date: Sun Apr 10 01:21:51 UTC 2016
New revision: 412884
URL: https://svnweb.freebsd.org/changeset/ports/412884

Log:
  games/taipan: fix out of bounds array subscript

  taipan.c:2709:7: warning: array index 4 is past the end of the array (which contains 4 elements) [-Warray-bounds]

  PR:		206771
  Submitted by:	Dave Walton <dw-fbsd@digger.net>
  Submitted by:	c.brinkhaus@t-online.de

Changes:
  head/games/taipan/Makefile
  head/games/taipan/files/patch-taipan.c
Comment 14 commit-hook freebsd_committer freebsd_triage 2016-04-10 01:22:46 UTC
A commit references this bug:

Author: junovitch
Date: Sun Apr 10 01:22:24 UTC 2016
New revision: 412885
URL: https://svnweb.freebsd.org/changeset/ports/412885

Log:
  MFH: r412884

  games/taipan: fix out of bounds array subscript

  taipan.c:2709:7: warning: array index 4 is past the end of the array (which contains 4 elements) [-Warray-bounds]

  PR:		206771
  Submitted by:	Dave Walton <dw-fbsd@digger.net>
  Submitted by:	c.brinkhaus@t-online.de
  Approved by:	ports-secteam (with hat)

Changes:
_U  branches/2016Q2/
  branches/2016Q2/games/taipan/Makefile
  branches/2016Q2/games/taipan/files/patch-taipan.c
Comment 15 Jason Unovitch freebsd_committer freebsd_triage 2016-04-10 01:29:12 UTC
Both GCC and Clang will warn when compiling outside of the ports collection so I just added this as is without any LICENSE changes and MFH'd this as a fix.

David, thank you for the report!

Christoph, thanks for the patch!  Technically PR patches would normally be generated from doing something along the lines of `cd /usr/ports/games/taipan; svn diff > ~/taipain.patch`.  You attached just the patch-taipan.c file.  That was fine in this simple case as it just replaced the existing patch-taipan.c file and at a minimal required a PORTREVISION bump to the Makefile.  That's easy enough for me to do pre-commit but keep this in mind and take a look at the helpful guidance in the Porter's Handbook next time. [1]

[1] https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/