From nobody@FreeBSD.org  Sun Nov 11 15:58:05 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 3EDE984D
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Nov 2012 15:58:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id CE35B8FC1D
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Nov 2012 15:46:16 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id qABFkGVO083602
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 11 Nov 2012 15:46:16 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id qABFkG65083601;
	Sun, 11 Nov 2012 15:46:16 GMT
	(envelope-from nobody)
Message-Id: <201211111546.qABFkG65083601@red.freebsd.org>
Date: Sun, 11 Nov 2012 15:46:16 GMT
From: Christian Gusenbauer <c47g@gmx.at>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ports/astrolog crashes on amd64
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         173561
>Category:       ports
>Synopsis:       ports/astrolog crashes on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 11 16:00:00 UTC 2012
>Closed-Date:    Thu Nov 22 16:46:32 UTC 2012
>Last-Modified:  Thu Nov 22 16:46:32 UTC 2012
>Originator:     Christian Gusenbauer
>Release:        FreeBSD 9.1-PRERELEASE
>Organization:
>Environment:
FreeBSD bones 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #2 r242827: Fri Nov  9 18:08:58 CET 2012     root@bones:/usr/obj/spare/tmp/src-stable9/sys/BONES  amd64
>Description:
astrolog crashes due to a 64/32 bit problem when calculating crc32
>How-To-Repeat:
call astrolog with the following parameters:
astrolog -R0 1 2 3 4 5 6 7 8 9 10 16 21 -A 5 -a
and enter some reasonable values when asked

eg:
[root@testjail ~]# astrolog -R0 1 2 3 4 5 6 7 8 9 10 16 21 -A 5 -a   
** Astrolog version 5.41G (See '-Hc' switch for copyrights and credits.) **
   Invoke as 'astrolog -H' for list of command line options.
Enter month for chart (e.g. '8' 'Aug') > 8
Enter day   for chart (e.g. '1' '31')  > 1
Enter year  for chart (e.g. '1995')    > 1995
Enter time  for chart (e.g. '18:30' '6:30pm')   > 18:30
Enter if Daylight time in effect (e.g. 'y' '1') > 
Value 10000 out of range from -24 to 24.
Enter if Daylight time in effect (e.g. 'y' '1') > y
Enter time zone (e.g. '5' 'ET' for Eastern)     > 5
Enter Longitude of place (e.g. '122W20') > 122W20
Enter Latitude  of place (e.g. '47N36')  > 47N36
Enter name or title for chart  > sdf
Enter name of city or location > sdf

Astrolog 5.41G chart for sdf
Tue Aug  1, 1995 18:30:00 (DT -5:00 GMT)
sdf 122:20:00W 47:36:00N

Segmentation fault: 11 (core dumped)

>Fix:
apply the attached patch (which is a shar) which changes the "unsigned long" data type to an "u_int32_t" and "long" to "int32_t"

Patch attached with submission follows:

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	patch-sweph.c
#	patch-swephlib.c
#	patch-swephlib.h
#
echo x - patch-sweph.c
sed 's/^X//' >patch-sweph.c << '76be21e082bbef0267b0472e230d7602'
X--- sweph.c.orig	2012-11-11 15:20:34.000000000 +0000
X+++ sweph.c	2012-11-11 15:21:18.000000000 +0000
X@@ -3406,8 +3406,8 @@
X   int retc;
X   int fendian, freord;
X   FILE *fp;
X-  long lng;
X-  unsigned long ulng;
X+  int32_t lng;
X+  u_int32_t ulng;
X   /*unsigned long ulng2;*/
X   long flen, fpos;
X   short nplan;
76be21e082bbef0267b0472e230d7602
echo x - patch-swephlib.c
sed 's/^X//' >patch-swephlib.c << '58049db2e885e2b27980bf12f93f154f'
X--- swephlib.c.orig	2012-11-11 15:05:06.000000000 +0000
X+++ swephlib.c	2012-11-11 15:15:50.000000000 +0000
X@@ -1541,15 +1541,15 @@
X  * The CRCs this code generates agree with the vendor-supplied Verilog models
X  * of several of the popular FDDI "MAC" chips.
X  */
X-static unsigned long crc32_table[256];
X+static u_int32_t crc32_table[256];
X /* Initialized first time "crc32()" is called. If you prefer, you can
X  * statically initialize it at compile time. [Another exercise.]
X  */
X 
X-unsigned long swi_crc32(unsigned char *buf, int len)
X+u_int32_t swi_crc32(unsigned char *buf, int len)
X {
X   unsigned char *p;
X-  unsigned long  crc;
X+  u_int32_t crc;
X   if (!crc32_table[1])    /* if not already done, */
X     init_crc32();   /* build table */
X   crc = 0xffffffff;       /* preload shift register, per CRC-32 spec */
X@@ -1566,7 +1566,7 @@
X static void init_crc32(void)
X {
X   long i, j;
X-  unsigned long c;
X+  u_int32_t c;
X   for (i = 0; i < 256; ++i) {
X     for (c = i << 24, j = 8; j > 0; --j)
X       c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
58049db2e885e2b27980bf12f93f154f
echo x - patch-swephlib.h
sed 's/^X//' >patch-swephlib.h << '58bb27a818046550a783134071c9a782'
X--- swephlib.h.orig	2012-11-11 15:09:36.000000000 +0000
X+++ swephlib.h	2012-11-11 15:09:53.000000000 +0000
X@@ -107,7 +107,7 @@
X extern void swi_gen_filename(double tjd, int ipli, char *fname);
X 
X /* cyclic redundancy checksum (CRC), 32 bit */
X-extern unsigned long swi_crc32(unsigned char *buf, int len);
X+extern u_int32_t swi_crc32(unsigned char *buf, int len);
X 
X extern int swi_cutstr(char *s, char *cutlist, char *cpos[], int nmax);
X extern char *swi_right_trim(char *s);
58bb27a818046550a783134071c9a782
exit



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: rm 
State-Changed-When: Wed Nov 21 19:56:04 UTC 2012 
State-Changed-Why:  
Christian, thank you for submission. misc/astrolog was fixed another 
way. Would you please update your ports tree and confirm that problem is 
gone (w/o your patch applied)? Thank you in advance. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173561 
State-Changed-From-To: feedback->closed 
State-Changed-By: rm 
State-Changed-When: Thu Nov 22 16:46:31 UTC 2012 
State-Changed-Why:  
Fixed another way. Thanks for your submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=173561 
>Unformatted:
