rpms/csound/devel csound-5.03.0-remote-fixes.patch, NONE, 1.1 csound.spec, 1.3, 1.4
Daniel Williams (dcbw)
fedora-extras-commits at redhat.com
Wed Oct 25 16:13:36 UTC 2006
Author: dcbw
Update of /cvs/extras/rpms/csound/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22591
Modified Files:
csound.spec
Added Files:
csound-5.03.0-remote-fixes.patch
Log Message:
* Wed Oct 25 2006 Dan Williams <dcbw at redhat.com> 5.03.0-5
- Fix the remote plugin's local IP address read code, add more error checking
csound-5.03.0-remote-fixes.patch:
--- NEW FILE csound-5.03.0-remote-fixes.patch ---
--- Csound5.03.0/OOps/remote.c.remote-debug 2006-10-23 08:18:21.000000000 -0400
+++ Csound5.03.0/OOps/remote.c 2006-10-25 12:08:20.000000000 -0400
@@ -36,15 +36,18 @@
#define ST(x) (((REMOTE_GLOBALS*) ((CSOUND*)csound)->remoteGlobals)->x)
+void remote_Cleanup(CSOUND *csound);
+
+
void remoteRESET(CSOUND *csound)
{
csound->remoteGlobals = NULL;
}
/* get the IPaddress of this machine */
-static void getIpAddress(char *ipaddr, char *ifname)
+static int getIpAddress(char *ipaddr, char *ifname)
{
-
+ int ret = -1;
#ifdef WIN32
/* VL 12/10/06: something needs to go here */
/* gethostbyname is the real answer; code below id unsafe */
@@ -57,25 +60,26 @@
memset(&sin, 0, sizeof (struct sockaddr_in));
memmove(&sin.sin_addr, he->h_addr_list[0], he->h_length);
strcpy(ipaddr, inet_ntoa (sin.sin_addr));
+ret = 0;
#else
struct ifreq ifr;
- int fd, i;
- unsigned char val;
+ int fd;
fd = socket(AF_INET,SOCK_DGRAM, 0);
if (fd >= 0) {
strcpy(ifr.ifr_name, ifname);
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
- for( i=2; i<6; i++){
- val = (unsigned char)ifr.ifr_ifru.ifru_addr.sa_data[i];
- sprintf(ipaddr, "%s%d%s", ipaddr, val, i==5?"":".");
- }
+ char *local;
+ local = inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr);
+ strcpy(ipaddr, local);
+ ret = 0;
}
}
close(fd);
#endif
+ return ret;
}
char remoteID(CSOUND *csound)
@@ -84,31 +88,83 @@
return ST(ipadrs)[len-1];
}
-static void callox(CSOUND *csound)
+static int callox(CSOUND *csound)
{
- if (csound->remoteGlobals == NULL)
+ if (csound->remoteGlobals == NULL) {
csound->remoteGlobals = csound->Calloc(csound, sizeof(REMOTE_GLOBALS));
+ if (csound->remoteGlobals == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize remote"
+ " globals."));
+ goto error;
+ }
+ }
ST(socksout) = (SOCK*)csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(SOCK));
+ if (ST(socksout) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize outgoing "
+ "socket table."));
+ goto error;
+ }
ST(socksin) = (int*) csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(int));
+ if (ST(socksin) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize incoming "
+ "socket table."));
+ goto error;
+ }
ST(insrfd_list) =
(int*) csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(int));
+ if (ST(insrfd_list) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize "
+ "insrfd_list."));
+ goto error;
+ }
ST(chnrfd_list) =
(int*) csound->Calloc(csound,(size_t)MAXREMOTES * sizeof(int));
+ if (ST(chnrfd_list) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize "
+ "chnrfd_list."));
+ goto error;
+ }
ST(insrfd) = (int*) csound->Calloc(csound,(size_t)129 * sizeof(int));
+ if (ST(insrfd) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize "
+ "insrfd table."));
+ goto error;
+ }
ST(chnrfd) = (int*) csound->Calloc(csound,(size_t)17 * sizeof(int));
+ if (ST(chnrfd) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize "
+ "chnrfd table."));
+ goto error;
+ }
ST(ipadrs) = (char*) csound->Calloc(csound,(size_t)15 * sizeof(char));
+ if (ST(ipadrs) == NULL) {
+ csound->Message(csound, Str("insufficient memory to initialize "
+ "local ip address."));
+ goto error;
+ }
+
+ /* get IP adrs of this machine */
+ /* FIXME: don't hardcode eth0 */
+ if (getIpAddress(ST(ipadrs), "eth0") < 0) {
+ csound->Message(csound, Str("unable to get local ip address."));
+ goto error;
+ }
+
+ return 0;
- getIpAddress(ST(ipadrs), "eth0"); /* get IP adrs of this machine */
+error:
+ /* Clean up anything we may have allocated before running out of memory */
+ remote_Cleanup(csound);
+ return -1;
}
/* Cleanup the above; called from musmon csoundCleanup */
void remote_Cleanup(CSOUND *csound)
{
int fd;
-/* if (csound->remoteGlobals == NULL) return; */
- if (ST(socksout) == NULL) return; /* if nothing allocated, return */
- else {
+ if (csound->remoteGlobals == NULL) return;
+ if (ST(socksout) != NULL) {
SOCK *sop = ST(socksout), *sop_end = sop + MAXREMOTES;
for ( ; sop < sop_end; sop++)
if ((fd = sop->rfd) > 0)
@@ -285,7 +341,12 @@
{ /* INSTR 0 opcode */
short nargs = p->INOCOUNT;
- if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+ if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+ if (callox(csound) < 0) {
+ csound->InitError(csound, Str("failed to initialize remote globals."));
+ return 0;
+ }
+ }
if (nargs < 3) {
csound->InitError(csound, Str("missing instr nos"));
return 0;
@@ -327,7 +388,12 @@
{ /* INSTR 0 opcode */
short nargs = p->INOCOUNT;
- if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+ if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+ if (callox(csound) < 0) {
+ csound->InitError(csound, Str("failed to initialize remote globals."));
+ return 0;
+ }
+ }
if (nargs < 2) {
csound->InitError(csound, Str("missing instr nos"));
return NOTOK;
@@ -357,7 +423,12 @@
{ /* INSTR 0 opcode */
short nargs = p->INOCOUNT;
- if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+ if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+ if (callox(csound) < 0) {
+ csound->InitError(csound, Str("failed to initialize remote globals."));
+ return 0;
+ }
+ }
if (nargs < 3) {
csound->InitError(csound, Str("missing channel nos"));
return NOTOK;
@@ -396,7 +467,12 @@
{ /* INSTR 0 opcode */
short nargs = p->INOCOUNT;
- if (csound->remoteGlobals==NULL || ST(socksin) == NULL) callox(csound);
+ if (csound->remoteGlobals==NULL || ST(socksin) == NULL) {
+ if (callox(csound) < 0) {
+ csound->InitError(csound, Str("failed to initialize remote globals."));
+ return 0;
+ }
+ }
if (nargs < 2) {
csound->InitError(csound, Str("missing channel nos"));
return NOTOK;
Index: csound.spec
===================================================================
RCS file: /cvs/extras/rpms/csound/devel/csound.spec,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- csound.spec 24 Oct 2006 04:35:22 -0000 1.3
+++ csound.spec 25 Oct 2006 16:13:06 -0000 1.4
@@ -11,7 +11,7 @@
Summary: Csound - sound synthesis language and library
Name: csound
Version: 5.03.0
-Release: 4%{?dist}
+Release: 5%{?dist}
URL: http://csound.sourceforge.net/
License: LGPL
Group: Applications/Multimedia
@@ -40,6 +40,7 @@
Patch1: csound-5.03.0-gstabs-disable-option.patch
Patch2: csound-5.03.0-no-usr-local.patch
Patch3: csound-5.03.0-disable-atsa.patch
+Patch4: csound-5.03.0-remote-fixes.patch
%description
@@ -165,6 +166,7 @@
%patch1 -p1 -b .gstabs-disable-option
%patch2 -p1 -b .no-usr-local
%patch3 -p1 -b .disable-atsa
+%patch4 -p1 -b .remote-fixes
tar xf %{SOURCE1}
@@ -376,6 +378,9 @@
%doc tutorial/*.py
%changelog
+* Wed Oct 25 2006 Dan Williams <dcbw at redhat.com> 5.03.0-5
+- Fix the remote plugin's local IP address read code, add more error checking
+
* Mon Oct 23 2006 Dan Williams <dcbw at redhat.com> 5.03.0-4
- Drop csound-5.03.0-uninitialized.patch, upstream
- Drop csound-5.03.0-printf-redef.patch, upstream
More information about the fedora-extras-commits
mailing list