csound: fix build w/ gcc-8.2.0

Signed-off-by: Jürgen Buchmüller <pullmoll@t-online.de>
This commit is contained in:
Jürgen Buchmüller 2018-09-24 19:19:55 +02:00
parent ecfeb59703
commit 55e1e4cd03
No known key found for this signature in database
GPG Key ID: 6764EC32352D0647
3 changed files with 118 additions and 0 deletions

View File

@ -9,3 +9,30 @@
int32_t j = 0;
int32_t len = 8192;
while (*fmt) {
--- Engine/csound_orc_expressions.c.orig 2018-09-24 19:09:36.956995269 +0200
+++ Engine/csound_orc_expressions.c 2018-09-24 19:11:09.401989759 +0200
@@ -826,10 +826,10 @@
static TREE *create_synthetic_ident(CSOUND *csound, int32 count)
{
- char *label = (char *)csound->Calloc(csound, 20);
+ char *label = (char *)csound->Calloc(csound, 32);
ORCTOKEN *token;
- snprintf(label, 20, "__synthetic_%"PRIi32, count);
+ snprintf(label, 32, "__synthetic_%"PRIi32, count);
if (UNLIKELY(PARSER_DEBUG))
csound->Message(csound, "Creating Synthetic T_IDENT: %s\n", label);
token = make_token(csound, label);
@@ -840,9 +840,9 @@
static TREE *create_synthetic_label(CSOUND *csound, int32 count)
{
- char *label = (char *)csound->Calloc(csound, 20);
+ char *label = (char *)csound->Calloc(csound, 32);
ORCTOKEN *token;
- snprintf(label, 20, "__synthetic_%"PRIi32":", count);
+ snprintf(label, 32, "__synthetic_%"PRIi32":", count);
if (UNLIKELY(PARSER_DEBUG))
csound->Message(csound, "Creating Synthetic label: %s\n", label);
token = make_label(csound, label);

View File

@ -0,0 +1,89 @@
Source: written by @pullmoll
Upstream: n/a
Reason: replace legacy sprintf with snprintf to avoid buffer overruns and fix gcc-8 warnings/errors.
--- OOps/schedule.c.orig 2018-09-24 18:54:29.373049365 +0200
+++ OOps/schedule.c 2018-09-24 19:04:41.067012905 +0200
@@ -56,22 +56,27 @@
return eventOpcodeI_(csound, &pp, 0, 'i');
}
-static void add_string_arg(char *s, const char *arg) {
- int32_t offs = strlen(s) ;
- //char *c = s;
- s += offs;
- *s++ = ' ';
-
- *s++ ='\"';
- while(*arg != '\0') {
- if(*arg == '\"')
- *s++ = '\\';
- *s++ = *arg++;
+static void add_string_arg(char *s, size_t size, const char *arg) {
+ size_t offs = strlen(s);
+ size_t len;
+ len = snprintf(s + offs, size - offs, " \"");
+ if (len <= 0)
+ return;
+ offs += len;
+ while (*arg != '\0') {
+ if (*arg == '\"') {
+ len = snprintf(s + offs, size - offs, "\\");
+ if (len <= 0)
+ return;
+ offs += len;
+ }
+ len = snprintf(s + offs, size - offs, "%c", *arg);
+ if (len <= 0)
+ return;
+ offs += len;
+ arg++;
}
-
- *s++ = '\"';
- *s = '\0';
- //printf("%s \n", c);
+ snprintf(s + offs, size - offs, "\"");
}
@@ -79,15 +84,16 @@
{
int32_t i;
int32_t argno = p->INOCOUNT+1;
+ size_t len;
char s[16384];
- sprintf(s, "i %f %f %f", *p->which, *p->when, *p->dur);
+ len = snprintf(s, sizeof(s), "i %f %f %f", *p->which, *p->when, *p->dur);
for (i=4; i < argno ; i++) {
MYFLT *arg = p->argums[i-4];
if (csoundGetTypeForArg(arg) == &CS_VAR_TYPE_S) {
- add_string_arg(s, ((STRINGDAT *)arg)->data);
- //sprintf(s, "%s \"%s\" ", s, ((STRINGDAT *)arg)->data);
+ add_string_arg(s, sizeof(s), ((STRINGDAT *)arg)->data);
+ //snprintf(s, sizeof(s), "%s \"%s\" ", s, ((STRINGDAT *)arg)->data);
}
- else sprintf(s, "%s %f", s, *arg);
+ else snprintf(s + len, sizeof(s) - len, " %f", *arg);
}
@@ -99,14 +105,14 @@
{
int32_t i;
int32_t argno = p->INOCOUNT+1;
+ size_t len;
char s[16384];
- sprintf(s, "i \"%s\" %f %f", ((STRINGDAT *)p->which)->data, *p->when, *p->dur);
+ len = snprintf(s, sizeof(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);
+ add_string_arg(s, sizeof(s), ((STRINGDAT *)arg)->data);
+ else snprintf(s + len, sizeof(s) - len, " %f", *arg);
}
//printf("%s\n", s);
csoundInputMessageInternal(csound, s);

View File

@ -19,6 +19,8 @@ distfiles="https://github.com/$pkgname/$pkgname/archive/$version.tar.gz"
checksum=f47df73ff270faa70bf53bad68edc85b2dc5623b9c73d06054cd03f5d3332dc0
nocross=yes
CXXFLAGS="-Wno-error"
post_install() {
vinstall ${FILESDIR}/csound.sh 755 etc/profile.d
# Avoid conflict with libextractor