ports/158878: [patch] textproc/dadadodo assumes long is 32 bits
Jonathan Hanna
jhanna at pangolin-systems.com
Wed Jul 13 22:20:10 UTC 2011
>Number: 158878
>Category: ports
>Synopsis: [patch] textproc/dadadodo assumes long is 32 bits
>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: Wed Jul 13 22:20:09 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Jonathan Hanna
>Release: FreeBSD 9.0-CURRENT amd64
>Organization:
>Environment:
Any platform where long is not 32 bits.
>Description:
u_long is assumed to be 32 bits, resulting in a failure to decode a
binary compiled data file and to produce text or stats output.
>How-To-Repeat:
Run on amd64 with a large input set (68MB of text was used).
A small input set will not trigger the problem as 16 or 8 bit integers
will then be used for the compiled data file.
>Fix:
diff -u -r -N dadadodo.orig/files/patch-files.c dadadodo/files/patch-files.c
--- dadadodo.orig/files/patch-files.c 1969-12-31 16:00:00.000000000 -0800
+++ dadadodo/files/patch-files.c 2011-07-13 14:39:10.845282150 -0700
@@ -0,0 +1,76 @@
+--- files.c.orig 2011-07-13 14:32:40.193282630 -0700
++++ files.c 2011-07-13 14:34:01.828282090 -0700
+@@ -49,7 +49,7 @@
+ static int
+ write_int32 (FILE *out, int x)
+ {
+- u_long lx = (u_long) x; /* no htonl, since we're writing big-endian */
++ u_int32_t lx = (u_int32_t) x; /* no htonl, since we're writing big-endian */
+ write_buf[write_fp++] = (lx >> 24);
+ write_buf[write_fp++] = (lx >> 16) & 0xFF;
+ write_buf[write_fp++] = (lx >> 8) & 0xFF;
+@@ -386,7 +386,7 @@
+
+
+ buf_size = 50;
+- buf = (void *) malloc (buf_size * sizeof(u_long));
++ buf = (void *) malloc (buf_size * sizeof(u_int32_t));
+ if (!buf) goto FAIL;
+
+
+@@ -415,15 +415,15 @@
+ switch (buf_elt_size)
+ {
+ case 4:
+- w->count = ntohl(((u_long *) buf) [0]);
+- w->start = ntohl(((u_long *) buf) [1]);
+- w->cap = ntohl(((u_long *) buf) [2]);
+- w->comma = ntohl(((u_long *) buf) [3]);
+- w->period = ntohl(((u_long *) buf) [4]);
+- w->quem = ntohl(((u_long *) buf) [5]);
+- w->bang = ntohl(((u_long *) buf) [6]);
+- w->succ_length = ntohl(((u_long *) buf) [7]);
+- w->pred_length = ntohl(((u_long *) buf) [8]);
++ w->count = ntohl(((u_int32_t *) buf) [0]);
++ w->start = ntohl(((u_int32_t *) buf) [1]);
++ w->cap = ntohl(((u_int32_t *) buf) [2]);
++ w->comma = ntohl(((u_int32_t *) buf) [3]);
++ w->period = ntohl(((u_int32_t *) buf) [4]);
++ w->quem = ntohl(((u_int32_t *) buf) [5]);
++ w->bang = ntohl(((u_int32_t *) buf) [6]);
++ w->succ_length = ntohl(((u_int32_t *) buf) [7]);
++ w->pred_length = ntohl(((u_int32_t *) buf) [8]);
+ break;
+ case 2:
+ w->count = ntohs(((u_short *) buf) [0]);
+@@ -487,8 +487,8 @@
+ switch (buf_elt_size)
+ {
+ case 4:
+- al_l->count = ntohl(((u_long *) buf) [j * 2]);
+- al_l->word = ntohl(((u_long *) buf) [j * 2 + 1]);
++ al_l->count = ntohl(((u_int32_t *) buf) [j * 2]);
++ al_l->word = ntohl(((u_int32_t *) buf) [j * 2 + 1]);
+ break;
+ case 2:
+ al_l->count = ntohs(((u_short *) buf) [j * 2]);
+@@ -520,8 +520,8 @@
+ switch (buf_elt_size)
+ {
+ case 4:
+- al_l->count = ntohl(((u_long *) buf) [j * 2]);
+- al_l->word = ntohl(((u_long *) buf) [j * 2 + 1]);
++ al_l->count = ntohl(((u_int32_t *) buf) [j * 2]);
++ al_l->word = ntohl(((u_int32_t *) buf) [j * 2 + 1]);
+ break;
+ case 2:
+ al_l->count = ntohs(((u_short *) buf) [j * 2]);
+@@ -588,7 +588,7 @@
+ if (buf == st)
+ {
+ for (i = 0; i < nstarters; i++)
+- st[i] = ntohl (((u_long *)buf) [i]);
++ st[i] = ntohl (((u_int32_t *)buf) [i]);
+ buf = 0;
+ }
+ else if (buf_elt_size == sizeof(u_short))
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list