Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Apr 2012 05:45:32 GMT
From:      Callum Gibson <callumgibson@optusnet.com.au>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/166658: audio/rplay: rplayd crashes on amd64
Message-ID:  <201204050545.q355jWFg080753@red.freebsd.org>
Resent-Message-ID: <201204050550.q355o4Qk026691@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         166658
>Category:       ports
>Synopsis:       audio/rplay: rplayd crashes on amd64
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 05 05:50:04 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Callum Gibson
>Release:        9.0-STABLE
>Organization:
>Environment:
FreeBSD merton 9.0-STABLE FreeBSD 9.0-STABLE #0: Mon Apr  2 15:30:20 EST 2012     root@merton:/usr/obj/usr/src/sys/MERTON  amd64

>Description:
rplayd (part of the audio/rplay port) crashes when parsing the rplay.hosts file. Investigation shows some references to undeclared libc functions which cause implicit return value of int. In addition, a number of standard library functions are reimplemented within rplay, and it includes its own regex library.

In attempting to solve the declaration issues and including appropriate headers, I decided it would be better to excise the redundant functions and switch to the standard regex library.

The attached patch implements these changes. I saved it as patch-ao in the port's files subdir and it applies and builds (more) cleanly.
>How-To-Repeat:
Try to start rplayd. Observe core file.
>Fix:
See attached patch.

Patch attached with submission follows:

diff -rwu /export/ports_work/usr/ports/audio/rplay/work/rplay-3.3.2/lib/Makefile.in rplay/lib/Makefile.in
--- lib/Makefile.in	1998-07-15 08:35:23.000000000 +1000
+++ rplay/lib/Makefile.in	2012-04-05 12:54:44.000000000 +1000
@@ -13,8 +13,8 @@
 		$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
 
 TARGET=		librp.a
-SRCS=		getopt.c getopt1.c hash.c strdup.c tilde.c xmalloc.c
-OBJS=		getopt.o getopt1.o hash.o strdup.o tilde.o xmalloc.o
+SRCS=		hash.c tilde.c xmalloc.c
+OBJS=		hash.o tilde.o xmalloc.o
 
 all:		$(TARGET)
 
diff -rwu /export/ports_work/usr/ports/audio/rplay/work/rplay-3.3.2/rplayd/Makefile.in rplay/rplayd/Makefile.in
--- rplayd/Makefile.in	2012-04-05 15:19:53.000000000 +1000
+++ rplay/rplayd/Makefile.in	2012-04-05 15:21:58.000000000 +1000
@@ -25,7 +25,7 @@
 		$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
 
 LDFLAGS=	$(LD_OPTIONS) -L../librplay -lrplay -L../lib -lrp \
-		-L../adpcm -ladpcm @GSM_LIBS@ -L../rx -lrx @LDFLAGS@ @LIBS@ -lm
+		-L../adpcm -ladpcm @GSM_LIBS@ @LDFLAGS@ @LIBS@ -lm
 
 TARGET=		rplayd
 
diff -rwu /export/ports_work/usr/ports/audio/rplay/work/rplay-3.3.2/rplayd/helper.c rplay/rplayd/helper.c
--- rplayd/helper.c	1999-03-10 18:58:03.000000000 +1100
+++ rplay/rplayd/helper.c	2012-04-05 14:31:10.000000000 +1000
@@ -110,7 +110,7 @@
 	    done(1);
 	}
 	//memset ((char *) &hp->pattern, 0, sizeof (hp->pattern));
-	error = regncomp(&hp->pattern, pat, strlen(pat), REG_ICASE | REG_NOSUB);
+	error = regcomp(&hp->pattern, pat, REG_EXTENDED | REG_ICASE | REG_NOSUB);
 	if (error)
 	{
 	    report(REPORT_ERROR, "helper_read: %d line %d\n", error, line);
@@ -188,7 +188,7 @@
 
     for (hp = helpers; hp; hp = hp->next)
     {
-	if (regnexec(&hp->pattern, sound, strlen(sound), 0, 0, 0) == 0)
+	if (regexec(&hp->pattern, sound, 0, 0, 0) == 0)
 	{
 	    return hp;
 	}
diff -rwu /export/ports_work/usr/ports/audio/rplay/work/rplay-3.3.2/rplayd/host.c rplay/rplayd/host.c
--- rplayd/host.c	1999-06-09 16:27:44.000000000 +1000
+++ rplay/rplayd/host.c	2012-04-05 14:14:12.000000000 +1000
@@ -95,10 +95,10 @@
     //memset ((char *) &access_write, 0, sizeof (access_write));
     //memset ((char *) &access_execute, 0, sizeof (access_execute));
 
-    strcpy(expr_read, "^\\(");
-    strcpy(expr_write, "^\\(");
-    strcpy(expr_execute, "^\\(");
-    strcpy(expr_monitor, "^\\(");
+    strcpy(expr_read, "^(");
+    strcpy(expr_write, "^(");
+    strcpy(expr_execute, "^(");
+    strcpy(expr_monitor, "^(");
 
     do
     {
@@ -162,7 +162,7 @@
 
     if (strlen(expr_read) == 3)
     {
-	strcat(expr_read, "\\)");
+	strcat(expr_read, ")");
     }
     else
     {
@@ -171,7 +171,7 @@
     strcat(expr_read, "$");
     if (strlen(expr_write) == 3)
     {
-	strcat(expr_write, "\\)");
+	strcat(expr_write, ")");
     }
     else
     {
@@ -180,7 +180,7 @@
     strcat(expr_write, "$");
     if (strlen(expr_execute) == 3)
     {
-	strcat(expr_execute, "\\)");
+	strcat(expr_execute, ")");
     }
     else
     {
@@ -189,7 +189,7 @@
     strcat(expr_execute, "$");
     if (strlen(expr_monitor) == 3)
     {
-	strcat(expr_monitor, "\\)");
+	strcat(expr_monitor, ")");
     }
     else
     {
@@ -197,35 +197,35 @@
     }
     strcat(expr_monitor, "$");
 
-    error = regncomp(&access_read, expr_read, strlen(expr_read),
-		     REG_ICASE | REG_NOSUB);
+    error = regcomp(&access_read, expr_read,
+		     REG_EXTENDED | REG_ICASE | REG_NOSUB);
     if (error)
     {
-	report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
+	report(REPORT_ERROR, "host_read: regcomp: %d\n", error);
 	done(1);
     }
 
-    error = regncomp(&access_write, expr_write, strlen(expr_write),
-		     REG_ICASE | REG_NOSUB);
+    error = regcomp(&access_write, expr_write,
+		     REG_EXTENDED | REG_ICASE | REG_NOSUB);
     if (error)
     {
-	report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
+	report(REPORT_ERROR, "host_read: regcomp: %d\n", error);
 	done(1);
     }
 
-    error = regncomp(&access_execute, expr_execute, strlen(expr_execute),
-		     REG_ICASE | REG_NOSUB);
+    error = regcomp(&access_execute, expr_execute,
+		     REG_EXTENDED | REG_ICASE | REG_NOSUB);
     if (error)
     {
-	report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
+	report(REPORT_ERROR, "host_read: regcomp: %d\n", error);
 	done(1);
     }
 
-    error = regncomp(&access_monitor, expr_monitor, strlen(expr_monitor),
-		     REG_ICASE | REG_NOSUB);
+    error = regcomp(&access_monitor, expr_monitor,
+		     REG_EXTENDED | REG_ICASE | REG_NOSUB);
     if (error)
     {
-	report(REPORT_ERROR, "host_read: regncomp: %d\n", error);
+	report(REPORT_ERROR, "host_read: regcomp: %d\n", error);
 	done(1);
     }
 }
@@ -354,22 +354,22 @@
 	{
 	case HOST_READ:
 	    strcat(expr_read, re_name);
-	    strcat(expr_read, "\\|");
+	    strcat(expr_read, "|");
 	    break;
 
 	case HOST_WRITE:
 	    strcat(expr_write, re_name);
-	    strcat(expr_write, "\\|");
+	    strcat(expr_write, "|");
 	    break;
 
 	case HOST_EXECUTE:
 	    strcat(expr_execute, re_name);
-	    strcat(expr_execute, "\\|");
+	    strcat(expr_execute, "|");
 	    break;
 
 	case HOST_MONITOR:
 	    strcat(expr_monitor, re_name);
-	    strcat(expr_monitor, "\\|");
+	    strcat(expr_monitor, "|");
 	    break;
 
 	default:
@@ -432,7 +432,7 @@
 	done(1);
     }
 
-    n = regnexec(re, p, strlen(p), 0, 0, 0);
+    n = regexec(re, p, 0, 0, 0);
 
     return !n;
 }
diff -rwu /export/ports_work/usr/ports/audio/rplay/work/rplay-3.3.2/rplayd/native.c rplay/rplayd/native.c
--- rplayd/native.c	1999-03-10 18:58:03.000000000 +1100
+++ rplay/rplayd/native.c	2012-04-05 12:58:20.000000000 +1000
@@ -32,6 +32,7 @@
 #include "rplayd.h"
 #include "native.h"
 #include "ulaw.h"
+#include <string.h>
 
 /* Native means 16-bit signed. */
 
diff -rwu /export/ports_work/usr/ports/audio/rplay/work/rplay-3.3.2/rplayd/sound.c rplay/rplayd/sound.c
--- rplayd/sound.c	1999-06-09 16:27:44.000000000 +1000
+++ rplay/rplayd/sound.c	2012-04-05 14:31:19.000000000 +1000
@@ -96,14 +96,14 @@
 
     dirs = strdup(BAD_DIRS);	/* XXX */
 
-    length = strlen("^\\(") + strlen("\\)") + strlen(dirs) + 1;
+    length = strlen("^(") + strlen(")") + strlen(dirs) + 1;
 
     //length += strlen ("^");
     for (p = dirs; *p; p++)
     {
 	if (*p == ':')
 	{
-	    length += strlen("\\|") - strlen(":");
+	    length += strlen("|") - strlen(":");
 	}
     }
 
@@ -119,7 +119,7 @@
     }
 
     first = 1;
-    strcpy(buf, "^\\(");
+    strcpy(buf, "^(");
     while (p = (char *) strtok(first ? dirs : 0, ":"))
     {
 	if (first)
@@ -129,12 +129,12 @@
 	}
 	else
 	{
-	    //strcat (buf, "\\|^");
-	    strcat(buf, "\\|");
+	    //strcat (buf, "|^");
+	    strcat(buf, "|");
 	}
 	strcat(buf, p);
     }
-    strcat(buf, "\\)");
+    strcat(buf, ")");
 
 #if 0
     report(REPORT_DEBUG, "bad_dirs=%s, strlen=%d, length=%d\n",
@@ -143,9 +143,9 @@
 
     //memset ((char *) &bad_dirs, 0, sizeof (bad_dirs));
 
-    if (regncomp(&bad_dirs, buf, strlen(buf), REG_ICASE | REG_NOSUB))
+    if (regcomp(&bad_dirs, buf, REG_EXTENDED | REG_ICASE | REG_NOSUB))
     {
-	report(REPORT_ERROR, "bad_dirs: regncomp failed\n");
+	report(REPORT_ERROR, "bad_dirs: regcomp failed\n");
 	done(1);
     }
 
@@ -162,7 +162,7 @@
 #endif
 {
     /* return 1 if bad */
-    return regnexec(&bad_dirs, dir, strlen(dir), 0, 0, 0) ? 0 : 1;
+    return regexec(&bad_dirs, dir, 0, 0, 0) ? 0 : 1;
 }
 
 #endif /* BAD_DIRS */


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204050545.q355jWFg080753>