[Asterisk-cvs] asterisk Makefile, 1.179, 1.180 channel.c, 1.218, 1.219 utils.c, 1.53, 1.54

kpfleming at lists.digium.com kpfleming at lists.digium.com
Thu Jul 14 20:32:32 CDT 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv6121

Modified Files:
	Makefile channel.c utils.c 
Log Message:
first phase of proper fix for portable string function problems (bug #4669)


Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/Makefile,v
retrieving revision 1.179
retrieving revision 1.180
diff -u -d -r1.179 -r1.180
--- Makefile	14 Jul 2005 19:40:15 -0000	1.179
+++ Makefile	15 Jul 2005 00:39:01 -0000	1.180
@@ -249,7 +249,7 @@
 CFLAGS+=-D__Darwin__
 endif
 ifeq (${OSARCH},FreeBSD)
-LIBS+=-lcrypto -lstrfunc
+LIBS+=-lcrypto
 endif
 ifeq (${OSARCH},NetBSD)
 LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/local/lib -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib -lncurses

Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -d -r1.218 -r1.219
--- channel.c	12 Jul 2005 16:00:23 -0000	1.218
+++ channel.c	15 Jul 2005 00:39:01 -0000	1.219
@@ -31,12 +31,6 @@
 #error "You need newer zaptel!  Please cvs update zaptel"
 #endif
 #endif
-#ifdef __FreeBSD__
-#include <strfunc.h>
-#if (!defined(__STRFUNC_H__) && (!defined(STRFUNC_H)))
-#error "Please install the strfunc library located in the ports collection at /usr/ports/devel/libstrfunc"
-#endif
-#endif
 
 #include "asterisk.h"
 
@@ -1759,8 +1753,8 @@
 			break; /* no frame */
 		if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP)
 			done = 1;	/* force a break */
-		else if (f->frametype == AST_FRAME_TEXT) {	/* what we want */
-			buf = strndup((char *)f->data, f->datalen);	/* dup and break */
+		else if (f->frametype == AST_FRAME_TEXT) {			/* what we want */
+			buf = ast_strndup((char *) f->data, f->datalen);	/* dup and break */
 			done = 1;
 		}
 		ast_frfree(f);

Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- utils.c	24 Jun 2005 22:45:15 -0000	1.53
+++ utils.c	15 Jul 2005 00:39:01 -0000	1.54
@@ -535,4 +535,28 @@
 		return NULL;
 	}
 }
-#endif /* LINUX */
+
+size_t ast_strnlen(const char *s, size_t n)
+{
+	size_t len;
+
+	for (len=0; len < n; len++)
+		if (s[len] == '\0')
+			break;
+
+	return len;
+}
+
+char *ast_strndup(const char *s, size_t n)
+{
+	size_t len = ast_strnlen(s, n);
+	char *new = malloc(len + 1);
+
+	if (!new)
+		return NULL;
+
+	new[len] = '\0';
+	return memcpy(new, s, len);
+}
+
+#endif /* !LINUX */




More information about the svn-commits mailing list