From nobody Tue Feb 21 07:26:04 2023 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PLW6h6vnNz3tB5P; Tue, 21 Feb 2023 07:26:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PLW6h6dSCz3jyB; Tue, 21 Feb 2023 07:26:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676964364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iTn0x079r4pKwwazze0uWMz85eDgEVyui4FJR++2csM=; b=MrUjJIgFGunXTDoXtAuFPgWTn835rJOS6rgILxHEUOS/ijuHEW9X6EzT86HyiIIt8F4Vw6 rI1CumqmfVBRjyUdyZ9WzrGrrag3zYvRwXXt9rI2Q+pUDzF5Hp3BZ5OS1AcmgNsitlKaCH ikLgblSlWBodETmbpk8yoLMrICelbXLc2u3jrswqBdBc2DvwIFDxGqWzQ7Oolx3iZ0q9vd Zx+45SoOdRyRg2g1LkylGDUL4Xit/Ln6CUxncbojHWzE1M8eRFpmm+XaVtaaeXdC0CXhI4 x4CiaQ0ssKkLkh50DK8jVoY4/EYD1T9YUGaxpP2OIUFp6388oG4fzyK2VlgPWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676964364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iTn0x079r4pKwwazze0uWMz85eDgEVyui4FJR++2csM=; b=ighAH/3jWTdF20gaqjeRBimSfYI3RGC1i/3M6PV/qHsjBj61JZIgR7Jna94zLQg1rm7Roi 9jtpVbcQX75ZVQ1pGA6P/k1ovKdP6UoZp+K0TCkWTqK9+7qrsS6RLGJqscGumGp2ZaQrCT qmmqet2ZEhLnDeqVvYgxr190q8UycVUc7sZw65xoxfPYgxEZiPt4a6P13c9Y9piwfnicC2 4rkuw+OgMLorIVU+3JB/Qhgm8XyKaddtPXAaI17ZX9g/SxQKLZ/Y4HhC/j4GhtTOp7CFOu GpDKZtWaRBVaIbKAX0GSsVZbD3StVhbWTk8rHd+K/VLP+yvg3MEOZHU84MdAQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676964364; a=rsa-sha256; cv=none; b=aF5FtlQKlW8ZdWFN2U22flyFbB5gSXZO9d4OD2PMaGbg2SNYMKFM3fOgPdKuMd6P+45yN0 3eQ13ZQM/Y86aA4tbxfNtr2sr+N8vhD14I2i2A3kLnlW+Mji7HAkw+bEsuLjynX77kkyDq Ud4EIOgjstDdvhNPiikKlgN8X9ywQZlKItceiLadrQXkp1S2ccrRIpXRmcZsQSnta4u0/t xP6VH7h91ySn3Rf2pzIQfUiUpGcLUVFFT3XgHBYp2KTjYAUhE6KttHyJKsGnBqgd4aOc+D BIoUM826zBYnpwtVS54EuVO1vPaPrwlQ+QG7y5w9vimgTzo3vUCSml+yDC3eIQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PLW6h5N0Vz1BZv; Tue, 21 Feb 2023 07:26:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31L7Q4N0052487; Tue, 21 Feb 2023 07:26:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31L7Q4Kb052486; Tue, 21 Feb 2023 07:26:04 GMT (envelope-from git) Date: Tue, 21 Feb 2023 07:26:04 GMT Message-Id: <202302210726.31L7Q4Kb052486@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Mikhail Teterin Subject: git: 39e57d44aa5a - main - audio/festival: fix crash due to overly aggressive optimization List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mi X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 39e57d44aa5af331426f14f1a54c07d6912a7b91 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mi: URL: https://cgit.FreeBSD.org/ports/commit/?id=39e57d44aa5af331426f14f1a54c07d6912a7b91 commit 39e57d44aa5af331426f14f1a54c07d6912a7b91 Author: Mikhail Teterin AuthorDate: 2023-02-21 07:23:22 +0000 Commit: Mikhail Teterin CommitDate: 2023-02-21 07:23:22 +0000 audio/festival: fix crash due to overly aggressive optimization Modern clang, optimize away checks like "if (this == NULL)", which are, indeed, redundant in good C++ code. Unfortunately, festival's code is not too good, and the checks are essential... PR: 269583 While here, eliminate some of the other warnings raised by both compiler and valgrind, and adapt one more patch from Debian. Bump PORTREVISION. --- audio/festival/Makefile | 8 +- audio/festival/files/patch-hts-buffer-bounds-check | 313 +++++++++++++++++++++ audio/festival/files/patch-warnings | 76 +++++ 3 files changed, 393 insertions(+), 4 deletions(-) diff --git a/audio/festival/Makefile b/audio/festival/Makefile index 3c143deffb14..05001c346ef7 100644 --- a/audio/festival/Makefile +++ b/audio/festival/Makefile @@ -1,6 +1,6 @@ PORTNAME= festival PORTVERSION= 2.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= audio accessibility MASTER_SITES= FESTIVAL DISTFILES= ${DISTNAME}-release.tar.gz \ @@ -27,13 +27,13 @@ WWW= https://www.cstr.ed.ac.uk/projects/festival/ OPTIONS_DEFINE= NAS OPTIONS_DEFAULT=NAS -CXXFLAGS+= -DFTLIBDIR=${LOCALBASE}/share/festival/lib +CXXFLAGS+= -DFTLIBDIR=${LOCALBASE}/share/festival/lib -fno-delete-null-pointer-checks CONFIGURE_WRKSRC=${WRKDIR}/festival USES= gmake SPEECHTOOLS= ${WRKSRC}/speech_tools FESTIVAL= ${WRKSRC}/festival -MAKE_ARGS+= CC="${CC}" GCC="${CC}" \ - CXX="${CXX}" GXX="${CXX}" \ +MAKE_ARGS+= CC="${CCACHE_BIN} ${CC}" GCC="${CCACHE_BIN} ${CC}" \ + CXX="${CCACHE_BIN} ${CXX}" GXX="${CCACHE_BIN} ${CXX}" \ EST_HOME=${SPEECHTOOLS} WRKSRC= ${WRKDIR} diff --git a/audio/festival/files/patch-hts-buffer-bounds-check b/audio/festival/files/patch-hts-buffer-bounds-check new file mode 100644 index 000000000000..0cb94a0aa357 --- /dev/null +++ b/audio/festival/files/patch-hts-buffer-bounds-check @@ -0,0 +1,313 @@ +Obtained from Debian. Original description follows: + +Description: HTS engine does not check buffer bounds in some functions. +This patch adds bounds checking to prevent writing past the end of the buffer. + +Author: Peter Drysdale + +--- festival/src/modules/hts_engine/HTS_engine.c ++++ festival/src/modules/hts_engine/HTS_engine.c +@@ -467,7 +467,7 @@ + } + + /* HTS_Engine_synthesize_from_strings: synthesize speech from strings */ +-HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, char **lines, size_t num_lines) ++HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, const char **lines, size_t num_lines) + { + HTS_Engine_refresh(engine); + HTS_Label_load_from_strings(&engine->label, engine->condition.sampling_frequency, engine->condition.fperiod, lines, num_lines); +--- festival/src/modules/hts_engine/HTS_engine.h ++++ festival/src/modules/hts_engine/HTS_engine.h +@@ -427,7 +427,7 @@ + HTS_Boolean HTS_Engine_synthesize_from_fn(HTS_Engine * engine, const char *fn); + + /* HTS_Engine_synthesize_from_strings: synthesize speech from string list */ +-HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, char **lines, size_t num_lines); ++HTS_Boolean HTS_Engine_synthesize_from_strings(HTS_Engine * engine, const char **lines, size_t num_lines); + + /* HTS_Engine_save_information: save trace information */ + void HTS_Engine_save_information(HTS_Engine * engine, FILE * fp); +--- festival/src/modules/hts_engine/HTS_hidden.h ++++ festival/src/modules/hts_engine/HTS_hidden.h +@@ -117,16 +117,16 @@ + size_t HTS_fwrite_little_endian(const void *buf, size_t size, size_t n, FILE * fp); + + /* HTS_get_pattern_token: get pattern token (single/double quote can be used) */ +-HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff); ++HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff, size_t bufflen); + + /* HTS_get_token: get token from file pointer (separators are space,tab,line break) */ +-HTS_Boolean HTS_get_token_from_fp(HTS_File * fp, char *buff); ++HTS_Boolean HTS_get_token_from_fp(HTS_File * fp, char *buff, size_t bufflen); + + /* HTS_get_token: get token from file pointer with specified separator */ + HTS_Boolean HTS_get_token_from_fp_with_separator(HTS_File * fp, char *buff, char separator); + + /* HTS_get_token_from_string: get token from string (separator are space,tab,line break) */ +-HTS_Boolean HTS_get_token_from_string(const char *string, size_t * index, char *buff); ++HTS_Boolean HTS_get_token_from_string(const char *string, size_t * index, char *buff, size_t bufflen); + + /* HTS_get_token_from_string_with_separator: get token from string with specified separator */ + HTS_Boolean HTS_get_token_from_string_with_separator(const char *str, size_t * index, char *buff, char separator); +@@ -248,7 +248,7 @@ + void HTS_Label_load_from_fn(HTS_Label * label, size_t sampling_rate, size_t fperiod, const char *fn); + + /* HTS_Label_load_from_strings: load label list from string list */ +-void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, char **lines, size_t num_lines); ++void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, const char **lines, size_t num_lines); + + /* HTS_Label_get_size: get number of label string */ + size_t HTS_Label_get_size(HTS_Label * label); +--- festival/src/modules/hts_engine/HTS_misc.c ++++ festival/src/modules/hts_engine/HTS_misc.c +@@ -333,7 +333,7 @@ + } + + /* HTS_get_pattern_token: get pattern token (single/double quote can be used) */ +-HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff) ++HTS_Boolean HTS_get_pattern_token(HTS_File * fp, char *buff, size_t bufflen) + { + char c; + size_t i; +@@ -369,7 +369,7 @@ + } + + i = 0; +- while (1) { ++ while (istring = HTS_strdup(buff); + + /* get pattern list */ +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + HTS_Question_clear(question); + return FALSE; + } +@@ -207,7 +207,7 @@ + last_pattern = NULL; + if (strcmp(buff, "{") == 0) { + while (1) { +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + HTS_Question_clear(question); + return FALSE; + } +@@ -218,7 +218,7 @@ + question->head = pattern; + pattern->string = HTS_strdup(buff); + pattern->next = NULL; +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + HTS_Question_clear(question); + return FALSE; + } +@@ -358,7 +358,7 @@ + if (tree == NULL || fp == NULL) + return FALSE; + +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + HTS_Tree_clear(tree); + return FALSE; + } +@@ -367,14 +367,14 @@ + tree->root = last_node = node; + + if (strcmp(buff, "{") == 0) { +- while (HTS_get_pattern_token(fp, buff) == TRUE && strcmp(buff, "}") != 0) { ++ while (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == TRUE && strcmp(buff, "}") != 0) { + node = HTS_Node_find(last_node, atoi(buff)); + if (node == NULL) { + HTS_error(0, "HTS_Tree_load: Cannot find node %d.\n", atoi(buff)); + HTS_Tree_clear(tree); + return FALSE; + } +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + HTS_Tree_clear(tree); + return FALSE; + } +@@ -389,7 +389,7 @@ + HTS_Node_initialize(node->yes); + HTS_Node_initialize(node->no); + +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + node->quest = NULL; + free(node->yes); + free(node->no); +@@ -403,7 +403,7 @@ + node->no->next = last_node; + last_node = node->no; + +- if (HTS_get_pattern_token(fp, buff) == FALSE) { ++ if (HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN) == FALSE) { + node->quest = NULL; + free(node->yes); + free(node->no); +@@ -495,7 +495,7 @@ + win->coefficient = (double **) HTS_calloc(win->size, sizeof(double *)); + /* set delta coefficents */ + for (i = 0; i < win->size; i++) { +- if (HTS_get_token_from_fp(fp[i], buff) == FALSE) { ++ if (HTS_get_token_from_fp(fp[i], buff, HTS_MAXBUFLEN) == FALSE) { + result = FALSE; + fsize = 1; + } else { +@@ -508,7 +508,7 @@ + /* read coefficients */ + win->coefficient[i] = (double *) HTS_calloc(fsize, sizeof(double)); + for (j = 0; j < fsize; j++) { +- if (HTS_get_token_from_fp(fp[i], buff) == FALSE) { ++ if (HTS_get_token_from_fp(fp[i], buff, HTS_MAXBUFLEN) == FALSE) { + result = FALSE; + win->coefficient[i][j] = 0.0; + } else { +@@ -610,7 +610,7 @@ + last_question = NULL; + last_tree = NULL; + while (!HTS_feof(fp)) { +- HTS_get_pattern_token(fp, buff); ++ HTS_get_pattern_token(fp, buff, HTS_MAXBUFLEN); + /* parse questions */ + if (strcmp(buff, "QS") == 0) { + question = (HTS_Question *) HTS_calloc(1, sizeof(HTS_Question)); +--- festival/src/modules/hts_engine/HTS_label.c ++++ festival/src/modules/hts_engine/HTS_label.c +@@ -117,5 +117,5 @@ + + /* parse label file */ +- while (HTS_get_token_from_fp(fp, buff)) { ++ while (HTS_get_token_from_fp(fp, buff, HTS_MAXBUFLEN)) { + if (!isgraph((int) buff[0])) + break; +@@ -130,9 +130,9 @@ + } + if (isdigit_string(buff)) { /* has frame infomation */ + start = atof(buff); +- HTS_get_token_from_fp(fp, buff); ++ HTS_get_token_from_fp(fp, buff, HTS_MAXBUFLEN); + end = atof(buff); +- HTS_get_token_from_fp(fp, buff); ++ HTS_get_token_from_fp(fp, buff, HTS_MAXBUFLEN); + lstring->start = rate * start; + lstring->end = rate * end; + } else { +@@ -154,7 +154,7 @@ + } + + /* HTS_Label_load_from_strings: load label from strings */ +-void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, char **lines, size_t num_lines) ++void HTS_Label_load_from_strings(HTS_Label * label, size_t sampling_rate, size_t fperiod, const char **lines, size_t num_lines) + { + char buff[HTS_MAXBUFLEN]; + HTS_LabelString *lstring = NULL; +@@ -182,11 +182,11 @@ + } + data_index = 0; + if (isdigit_string(lines[i])) { /* has frame infomation */ +- HTS_get_token_from_string(lines[i], &data_index, buff); ++ HTS_get_token_from_string(lines[i], &data_index, buff, HTS_MAXBUFLEN); + start = atof(buff); +- HTS_get_token_from_string(lines[i], &data_index, buff); ++ HTS_get_token_from_string(lines[i], &data_index, buff, HTS_MAXBUFLEN); + end = atof(buff); +- HTS_get_token_from_string(lines[i], &data_index, buff); ++ HTS_get_token_from_string(lines[i], &data_index, buff, HTS_MAXBUFLEN); + lstring->name = HTS_strdup(buff); + lstring->start = rate * start; + lstring->end = rate * end; diff --git a/audio/festival/files/patch-warnings b/audio/festival/files/patch-warnings new file mode 100644 index 000000000000..228b3a270848 --- /dev/null +++ b/audio/festival/files/patch-warnings @@ -0,0 +1,76 @@ +Address some of the warnings flagged by either compiler or valgrind. + + -mi +--- speech_tools/stats/EST_Discrete.cc 2010-11-05 10:12:43.000000000 -0400 ++++ speech_tools/stats/EST_Discrete.cc 2023-02-20 22:17:06.842236000 -0500 +@@ -152,5 +152,5 @@ + for (i=0; i