csound: Fix build with gcc8
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
@@ -29,6 +29,11 @@ SRC_URI = " \
|
||||
git://github.com/csound/csound.git \
|
||||
file://0001-Do-not-set-include-path-to-usr-local-include.patch \
|
||||
file://0002-Do-not-use-try_run-for-portaudio.patch \
|
||||
file://0003-strict-aliasing-errors.patch \
|
||||
file://0004-Engine-csound_orc_semantics.c-Fix-build-with-gcc8.patch \
|
||||
file://0005-InOut-pmidi.c-Fix-build-with-gcc8.patch \
|
||||
file://0006-fixed-unsafe-use-of-strncpy.patch \
|
||||
file://0007-util1-csd_util-cs.c-Fix-build-with-gcc8.patch \
|
||||
"
|
||||
SRCREV = "c6e19a041507c057a27927761ddb80deb4213eb6"
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
From 7e2f3f49670166804529c6b9ff1398f38999d921 Mon Sep 17 00:00:00 2001
|
||||
From: veplaini <victor.lazzarini@nuim.ie>
|
||||
Date: Fri, 11 May 2018 14:05:49 +0100
|
||||
Subject: [PATCH] strict aliasing errors
|
||||
|
||||
---
|
||||
Engine/musmon.c | 2 +-
|
||||
Engine/rdscor.c | 8 +++++---
|
||||
OOps/schedule.c | 19 ++++++++++++++-----
|
||||
3 files changed, 20 insertions(+), 9 deletions(-)
|
||||
|
||||
Upstream-Status: Backport
|
||||
|
||||
diff --git a/Engine/musmon.c b/Engine/musmon.c
|
||||
index 440642489..8f4cc22cf 100644
|
||||
--- a/Engine/musmon.c
|
||||
+++ b/Engine/musmon.c
|
||||
@@ -1033,7 +1033,7 @@ int sensevents(CSOUND *csound)
|
||||
if (!(rdscor(csound, e))){
|
||||
/* or rd nxt evt from scstr */
|
||||
e->opcod = 'e';
|
||||
- }
|
||||
+ }
|
||||
csound->currevent = e;
|
||||
|
||||
switch (e->opcod) {
|
||||
diff --git a/Engine/rdscor.c b/Engine/rdscor.c
|
||||
index f39393725..fe6488cb2 100644
|
||||
--- a/Engine/rdscor.c
|
||||
+++ b/Engine/rdscor.c
|
||||
@@ -142,7 +142,7 @@ int rdscor(CSOUND *csound, EVTBLK *e) /* read next score-line from scorefile */
|
||||
{ /* presumes good format if warped */
|
||||
MYFLT *pp, *plim;
|
||||
int c;
|
||||
-
|
||||
+
|
||||
e->pinstance = NULL;
|
||||
if (csound->scstr == NULL ||
|
||||
csound->scstr->body[0] == '\0') { /* if no concurrent scorefile */
|
||||
@@ -151,12 +151,14 @@ int rdscor(CSOUND *csound, EVTBLK *e) /* read next score-line from scorefile */
|
||||
e->p[2] = FL(INF);
|
||||
e->p2orig = FL(INF);
|
||||
e->pcnt = 2;
|
||||
+
|
||||
return(1);
|
||||
}
|
||||
+
|
||||
/* else read the real score */
|
||||
while ((c = corfile_getc(csound->scstr)) != '\0') {
|
||||
csound->scnt = 0;
|
||||
- switch (c) {
|
||||
+ switch (c) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
@@ -193,7 +195,7 @@ int rdscor(CSOUND *csound, EVTBLK *e) /* read next score-line from scorefile */
|
||||
goto setp;
|
||||
case 'e':
|
||||
e->opcod = c;
|
||||
- e->pcnt = 0;
|
||||
+ e->pcnt = 0;
|
||||
return(1);
|
||||
case EOF: /* necessary for cscoreGetEvent */
|
||||
return(0);
|
||||
diff --git a/OOps/schedule.c b/OOps/schedule.c
|
||||
index b87897ec9..6dd60e94f 100644
|
||||
--- a/OOps/schedule.c
|
||||
+++ b/OOps/schedule.c
|
||||
@@ -79,7 +79,7 @@ int32_t schedule_N(CSOUND *csound, SCHED *p)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t argno = p->INOCOUNT+1;
|
||||
- char s[16384];
|
||||
+ char s[16384], sf[64];
|
||||
sprintf(s, "i %f %f %f", *p->which, *p->when, *p->dur);
|
||||
for (i=4; i < argno ; i++) {
|
||||
MYFLT *arg = p->argums[i-4];
|
||||
@@ -87,8 +87,12 @@ int32_t schedule_N(CSOUND *csound, SCHED *p)
|
||||
add_string_arg(s, ((STRINGDAT *)arg)->data);
|
||||
//sprintf(s, "%s \"%s\" ", s, ((STRINGDAT *)arg)->data);
|
||||
}
|
||||
- else sprintf(s, "%s %f", s, *arg);
|
||||
-
|
||||
+ else {
|
||||
+ sprintf(sf, " %f", *arg);
|
||||
+ if(strlen(s) < 16384)
|
||||
+ strncat(s, sf, 16384-strlen(s));
|
||||
+ //sprintf(s, "%s %f", s, *arg);
|
||||
+ }
|
||||
}
|
||||
|
||||
csoundInputMessageInternal(csound, s);
|
||||
@@ -99,14 +103,19 @@ int32_t schedule_SN(CSOUND *csound, SCHED *p)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t argno = p->INOCOUNT+1;
|
||||
- char s[16384];
|
||||
+ char s[16384], sf[64];
|
||||
sprintf(s, "i \"%s\" %f %f", ((STRINGDAT *)p->which)->data, *p->when, *p->dur);
|
||||
for (i=4; i < argno ; i++) {
|
||||
MYFLT *arg = p->argums[i-4];
|
||||
if (csoundGetTypeForArg(arg) == &CS_VAR_TYPE_S)
|
||||
//sprintf(s, "%s \"%s\" ", s, ((STRINGDAT *)arg)->data);
|
||||
add_string_arg(s, ((STRINGDAT *)arg)->data);
|
||||
- else sprintf(s, "%s %f", s, *arg);
|
||||
+ else {
|
||||
+ sprintf(sf, " %f", *arg);
|
||||
+ if(strlen(s) < 16384)
|
||||
+ strncat(s, sf, 16384-strlen(s));
|
||||
+ //sprintf(s, "%s %f", s, *arg);
|
||||
+ }
|
||||
}
|
||||
//printf("%s\n", s);
|
||||
csoundInputMessageInternal(csound, s);
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
From 9d4fef967e622faec90bbed00fb00383e85e328c Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
|
||||
Date: Mon, 2 Jul 2018 00:22:14 +0200
|
||||
Subject: [PATCH] Engine/csound_orc_semantics.c: Fix build with gcc8
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:73:7: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
|
||||
strncpy(retVal, str, len);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:69:11: note: length computed here
|
||||
len = strlen(str);
|
||||
^~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c: In function 'get_arg_type2':
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:450:7: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
|
||||
strncpy(inArgTypes, argTypeLeft, len1);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:446:14: note: length computed here
|
||||
len1 = strlen(argTypeLeft);
|
||||
^~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:451:7: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
|
||||
strncpy(inArgTypes + len1, argTypeRight, len2);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:447:14: note: length computed here
|
||||
len2 = strlen(argTypeRight);
|
||||
^~~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:392:9: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
|
||||
strncpy(inArgTypes, argTypeLeft, len1);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:388:16: note: length computed here
|
||||
len1 = strlen(argTypeLeft);
|
||||
^~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:393:9: error: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
|
||||
strncpy(inArgTypes + len1, argTypeRight, len2);
|
||||
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/home/superandy/tmp/oe-core-glibc/work/cortexa7t2hf-neon-vfpv4-angstrom-linux-gnueabi/csound/6.11.0-r0/git/Engine/csound_orc_semantics.c:389:16: note: length computed here
|
||||
len2 = strlen(argTypeRight);
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
|
||||
---
|
||||
Engine/csound_orc_semantics.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/Engine/csound_orc_semantics.c b/Engine/csound_orc_semantics.c
|
||||
index 6b6255d9c..5985b2435 100644
|
||||
--- a/Engine/csound_orc_semantics.c
|
||||
+++ b/Engine/csound_orc_semantics.c
|
||||
@@ -70,7 +70,7 @@ char* cs_strdup(CSOUND* csound, char* str) {
|
||||
retVal = csound->Malloc(csound, len + 1);
|
||||
|
||||
if (len > 0) {
|
||||
- strncpy(retVal, str, len);
|
||||
+ strncpy(retVal, str, len+1);
|
||||
}
|
||||
retVal[len] = '\0';
|
||||
|
||||
@@ -389,8 +389,8 @@ char* get_arg_type2(CSOUND* csound, TREE* tree, TYPE_TABLE* typeTable)
|
||||
len2 = strlen(argTypeRight);
|
||||
inArgTypes = csound->Malloc(csound, len1 + len2 + 1);
|
||||
|
||||
- strncpy(inArgTypes, argTypeLeft, len1);
|
||||
- strncpy(inArgTypes + len1, argTypeRight, len2);
|
||||
+ strncpy(inArgTypes, argTypeLeft, len1+1);
|
||||
+ strncpy(inArgTypes + len1, argTypeRight, len2+1);
|
||||
|
||||
inArgTypes[len1 + len2] = '\0';
|
||||
|
||||
@@ -447,8 +447,8 @@ char* get_arg_type2(CSOUND* csound, TREE* tree, TYPE_TABLE* typeTable)
|
||||
len2 = strlen(argTypeRight);
|
||||
inArgTypes = csound->Malloc(csound, len1 + len2 + 1);
|
||||
|
||||
- strncpy(inArgTypes, argTypeLeft, len1);
|
||||
- strncpy(inArgTypes + len1, argTypeRight, len2);
|
||||
+ strncpy(inArgTypes, argTypeLeft, len1+1);
|
||||
+ strncpy(inArgTypes + len1, argTypeRight, len2+1);
|
||||
|
||||
inArgTypes[len1 + len2] = '\0';
|
||||
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
From 599e78547a32ec3cd01ce9e007531b765f4168ee Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
|
||||
Date: Mon, 2 Jul 2018 00:39:01 +0200
|
||||
Subject: [PATCH] InOut/pmidi.c: Fix build with gcc8
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
|
||||
---
|
||||
InOut/pmidi.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/InOut/pmidi.c b/InOut/pmidi.c
|
||||
index 8dfe0e71d..f6de618cf 100644
|
||||
--- a/InOut/pmidi.c
|
||||
+++ b/InOut/pmidi.c
|
||||
@@ -188,14 +188,14 @@ static int listDevices(CSOUND *csound, CS_MIDIDEVICE *list, int isOutput){
|
||||
for (i = 0; i < cnt; i++) {
|
||||
info = portMidi_getDeviceInfo(i, isOutput);
|
||||
if (info->name != NULL)
|
||||
- strncpy(list[i].device_name, info->name, 63);
|
||||
+ strncpy(list[i].device_name, info->name, 64);
|
||||
snprintf(tmp, 64, "%d", i);
|
||||
- strncpy(list[i].device_id, tmp, 63);
|
||||
+ strncpy(list[i].device_id, tmp, 64);
|
||||
list[i].isOutput = isOutput;
|
||||
if (info->interf != NULL)
|
||||
- strncpy(list[i].interface_name, info->interf, 63);
|
||||
+ strncpy(list[i].interface_name, info->interf, 64);
|
||||
else strcpy(list[i].interface_name, "");
|
||||
- strncpy(list[i].midi_module, drv, 63);
|
||||
+ strncpy(list[i].midi_module, drv, 64);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
From 3d5e27ea49f67b38a39ad831d18e8abd17b3a9bc Mon Sep 17 00:00:00 2001
|
||||
From: vlazzarini <vlazzarini@mu.ie>
|
||||
Date: Sun, 27 May 2018 11:18:08 +0100
|
||||
Subject: [PATCH] fixed unsafe use of strncpy
|
||||
|
||||
Upstream-Status: Backport
|
||||
|
||||
---
|
||||
util1/scot/scot.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/util1/scot/scot.c b/util1/scot/scot.c
|
||||
index 857bb08ce..5b9a0eb96 100644
|
||||
--- a/util1/scot/scot.c
|
||||
+++ b/util1/scot/scot.c
|
||||
@@ -684,7 +684,7 @@ void addparam(int n, /* number of param to change */
|
||||
|
||||
ps = findparam(n, ptop);
|
||||
if (strcmp(s, "."))
|
||||
- strncpy(ps, s, 1+strlen(s));
|
||||
+ strncpy(ps, s, 31);
|
||||
}
|
||||
|
||||
static /* returns pointer to */
|
||||
--
|
||||
2.14.4
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
From a070eaef29510f9138055896975917211d4fe61f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com>
|
||||
Date: Mon, 2 Jul 2018 00:55:16 +0200
|
||||
Subject: [PATCH] util1/csd_util/cs.c: Fix build with gcc8
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Upstream-Status: Pending
|
||||
|
||||
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
|
||||
---
|
||||
util1/csd_util/cs.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/util1/csd_util/cs.c b/util1/csd_util/cs.c
|
||||
index a05ee3b43..768843fff 100644
|
||||
--- a/util1/csd_util/cs.c
|
||||
+++ b/util1/csd_util/cs.c
|
||||
@@ -385,7 +385,7 @@ int main(int argc, char **argv)
|
||||
while (--j) {
|
||||
i++;
|
||||
if (argv[i][0] != '-' && i < 3 && tmp[0] == '\0') {
|
||||
- strncpy(tmp, argv[i],256);
|
||||
+ strncpy(tmp, argv[i],255);
|
||||
/* strip extension */
|
||||
if (is_orc(tmp) || is_sco(tmp) || is_mid(tmp) || is_csd(tmp))
|
||||
tmp[strlen(tmp) - 4] = '\0';
|
||||
@@ -428,12 +428,12 @@ int main(int argc, char **argv)
|
||||
/* (the last option has the highest precedence) */
|
||||
s = getenv("CSOUND");
|
||||
if (s != NULL) /* get default setting from CSOUND, if available */
|
||||
- strncpy(tmp, s, 256);
|
||||
+ strncpy(tmp, s, 255);
|
||||
for (i = (int) strlen(optlst); --i >= 0; ) {
|
||||
sprintf(tmp2, "CSOUND_%c", optlst[i]);
|
||||
s = getenv(tmp2);
|
||||
if (s != NULL) {
|
||||
- strncpy(tmp, s, 256);
|
||||
+ strncpy(tmp, s, 255);
|
||||
if (tmp[0] != '\0') break;
|
||||
}
|
||||
}
|
||||
--
|
||||
2.14.4
|
||||
|
||||
Reference in New Issue
Block a user