ports/149406: [patch] games/connect4: fix amd64 segfault
Anonymous
swell.k at gmail.com
Sat Aug 7 16:20:04 UTC 2010
>Number: 149406
>Category: ports
>Synopsis: [patch] games/connect4: fix amd64 segfault
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Aug 07 16:20:03 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Anonymous
>Release: FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
tested only on amd64 with/without -m32
>Description:
http://docs.freebsd.org/cgi/mid.cgi?86k4o3jznm.fsf
- attempt to fix amd64 by using `intptr_t' instead of `int' type[1]
- silence warninigs about implicit declaration of strcpy/exit
- rather than overriding group and mode just switch defaults for INSTALL_(PROGRAM|DATA)
- use DATADIR (cosmetic)
[1] I have absolutely no clue if it's the right type
>How-To-Repeat:
>Fix:
--- a.diff begins here ---
Index: games/connect4/Makefile
===================================================================
RCS file: /a/.cvsup/ports/games/connect4/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- games/connect4/Makefile 19 Mar 2004 23:56:42 -0000 1.14
+++ games/connect4/Makefile 7 Aug 2010 16:04:09 -0000
@@ -26,10 +26,18 @@ EXTRACT_AFTER_ARGS= | gunshar
NO_WRKSUBDIR= yes
MAN6= connect4.6
+SHAREGRP?= games
+SHAREMODE?= 664
+
+.if !defined(WITHOUT_SETGID)
+BINGRP?= games
+BINMODE?= 2555
+.endif
+
do-install:
- ${INSTALL_PROGRAM} -m 2755 -o root -g games ${WRKSRC}/c4 ${PREFIX}/bin/connect4
- @${MKDIR} ${PREFIX}/share/connect4
- ${INSTALL_DATA} -m 664 -o root -g games /dev/null ${PREFIX}/share/connect4/scores
+ ${INSTALL_PROGRAM} ${WRKSRC}/c4 ${PREFIX}/bin/connect4
+ ${MKDIR} ${DATADIR}
+ ${INSTALL_DATA} /dev/null ${DATADIR}/scores
${INSTALL_MAN} ${FILESDIR}/connect4.6 ${MANPREFIX}/man/man6
.include <bsd.port.mk>
Index: games/connect4/pkg-plist
===================================================================
RCS file: /a/.cvsup/ports/games/connect4/pkg-plist,v
retrieving revision 1.4
diff -u -p -r1.4 pkg-plist
--- games/connect4/pkg-plist 3 Nov 2000 12:50:56 -0000 1.4
+++ games/connect4/pkg-plist 7 Aug 2010 16:12:33 -0000
@@ -1,3 +1,3 @@
bin/connect4
-share/connect4/scores
- at dirrm share/connect4
+%%DATADIR%%/scores
+ at dirrm %%DATADIR%%
Index: games/connect4/files/patch-ab
===================================================================
RCS file: /a/.cvsup/ports/games/connect4/files/patch-ab,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 patch-ab
--- games/connect4/files/patch-ab 4 Jun 1997 03:21:13 -0000 1.1.1.1
+++ games/connect4/files/patch-ab 7 Aug 2010 16:05:03 -0000
@@ -1,8 +1,8 @@
*** c4.c.orig Tue Apr 15 22:06:03 1997
--- c4.c Tue Apr 15 22:16:29 1997
***************
-*** 11,16 ****
---- 11,18 ----
+*** 11,19 ****
+--- 11,23 ----
* BITNET: tcjones at WATER.bitnet
* Canadian domain: tcjones at dragon.uwaterloo.ca
*
@@ -11,6 +11,11 @@
*/
#include <stdio.h>
++ #include <string.h>
++ #include <stdlib.h>
+ #include <sys/types.h>
+ #include <ctype.h>
+ #include <pwd.h>
***************
*** 219,225 ****
register char *cp;
@@ -47,3 +52,26 @@
fprintf(stderr, "Could not read input line\n");
goodbye();
}
+***************
+*** 835,844 ****
+ char *last, *address;
+ while( environ[1] != 0 ) ++environ;
+ last = environ[0] + strlen(environ[0]);/* address of '\0' */
+! last = (char *)((int)last&(~03));/* word boundary */
+ *(int *)last = 0; /* clean out last word */
+ address = last +3 -strlen(message);
+! address = (char *)((int)address&(~03));/* word boundary */
+ *(int *)(address-4) = 0; /* clean out word below */
+ *(int *)(address-8) = 0; /* clean out word below */
+ strcpy( address, message );
+--- 839,848 ----
+ char *last, *address;
+ while( environ[1] != 0 ) ++environ;
+ last = environ[0] + strlen(environ[0]);/* address of '\0' */
+! last = (char *)((intptr_t)last&(~03));/* word boundary */
+ *(int *)last = 0; /* clean out last word */
+ address = last +3 -strlen(message);
+! address = (char *)((intptr_t)address&(~03));/* word boundary */
+ *(int *)(address-4) = 0; /* clean out word below */
+ *(int *)(address-8) = 0; /* clean out word below */
+ strcpy( address, message );
--- a.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list